SlideShare a Scribd company logo
1 of 12
C++ Programming: Class Creation Program Assignment
Instructions
Overview
The purpose of this assignment is to give you some practice
with creating your own classes. This program serves as the basis
for all of the other programming assignments in this class and
your future Computer Science classes.
Instructions
Construct a class named Square that has a floating-point data
member named side. The class should have a zero-argument
constructor that initializes this data member to 0. It should have
member functions named calcPerimeter() and calcArea() that
calculate the perimeter and area of a square respectively, a
member function setSide() to set the side of the square, a
member function getSide() to return the side, and a member
function showData() that displays the square’s side, perimeter,
and area. The formula for the area of a square is Area = side *
side. The formula for the perimeter of a square is Perimeter = 4
* side.
The class should use appropriate protection levels for the
member data and functions. It should also follow “principles of
minimalization”: that is, no member data should be part of a
class unless it is needed by most member functions of the
object. A general rule of thumb is that “if you can easily
calculate it, don’t store it.”
Use your class in a program that creates an instance of a Square
(utilizing the zero-argument constructor), prompts a user for a
side, calls the setSide() function to set the square’s side, and
then calls showData() to display the square’s side, perimeter,
and area. Your program should allow the user to enter new
square dimensions until the user enters -1. Be sure to include
appropriate error checking. Does it make sense to enter “abc”
as the side of a square? No. Therefore, you should ensure that
the user enters numeric data for the side. Negative numbers
(other than the -1 to exit) should also be prevented.
Style:
· Your lab should be constructed such that separate files are
used: Square.h (your class declaration file), Square.cpp (your
class implementation file), and SquareDriver.cpp (the file that
contains main() and any other functions that are not part of the
class).
The purpose of having separate files is for code resusability. If
other developers want to use your class in their programs, they
don't need main() as well. They should only have to "#include"
your class header file. As such, two separate files for the class
are needed to be able to hide the implementation details from
other developers. You want other developers to know how to
use your class (i.e. what functions are available and how they
are called -- this is called the "interface" of the class), but not
how they are implemented. If both the interface and the
implementation code are in the same file, this cannot be
accomplished. When you distribute your class to other
developers, the implementation (.cpp) file gets compiled, but
the interface (.h) doesn't. That way, the developer can use your
class, but he or she can't see or change your code in your class
functions.
· Never use “using namespace std;” in a header file. Here is a
link that describes why:
https://stackoverflow.com/questions/14575799/using-
namespace-std-in-a-header-file
· Note that when you follow the rule above and don’t use “using
namespace std;” in a header file, you have to remember to
prefix certain things with std:: (i.e. cout, cin, endl, string,
istream, ostream, and vector). If you fail to prefix these words
with std::, you will get a compilation error that is often quite
cryptic. Be on the lookout for this situation. It may save you
hours of debugging.
· All "get" functions should be declared as constant. In fact,
any function that does not change the data in the data members
should be declared as constant. This is a security measure that
prevents anyone from accidentally writing code in a function
that changes underlying data when the purpose of the function
is only to retrieve the data. In other words, "const" at the end
of a function provides protection of your data. The rationale is
that certain functions (e.g. those that merely return a data item
to the caller or even those that just print the data) should be
prevented from ever changing the underlying data. If a function
doesn't need "write" access to a data item, it shouldn't be
granted the access. This adheres to the “Principle of Least
Privilege,” which is a security principle that helps to protect the
integrity of your data.
One other thing that's important to know for future reference:
Whenever you make a function constant, it can't call another
function unless that function is also constant. It makes sense
that if you lock down an object in a function, you don't want to
open it up for modifications by calling another function that
allows it to be inadvertently altered. If you ever try to call a
function that is not constant from a function that is constant,
you will get a compilation error.
· showData() should not refer to the data members directly.
Instead, it should call getSide() to retrieve its value. Think of
your getters and setters as middlemen. You should try to avoid
accessing your data members directly due to maintenance
issues. Pretend that you decided to change the name of your
side variable to be "sid". You really should only have to make
that change in two functions: getSide and setSide. If you refer
to the private data members directly throughout your code,
you'll have a nightmare trying to make all the changes
necessary. If you always use the getters to retrieve your data,
any changes you make to the variable name will only necessitate
changes to your get function rather than your whole code base.
· CalcPerimeter, CalcArea, and ShowData should not have the
side passed in as an argument because side is a data member of
the class. Class functions have direct access to all data
members in their own class. By passing in an argument for the
value of the side, you're not using the value that has already
been stored in the data member. You're using the value that
you've passed in to the functions, which circumvents the whole
purpose of storing side in the class.
· Use good prompting (correct spelling and clear instructions),
output labeling, and modularization in your program and class.
· Be sure to avoid using global variables in your program unless
they are constants.
· Finally, be sure not to include any unnecessary libraries.
Deliverables:
· Complete the programming assignment described above and
submit your completed assignment in accordance with the
assignment submission policies.
To give you an idea of the general criteria that will be used for
grading, here is a checklist that you might find helpful:
Compiles and Executes without crashing
Word document contains screen shots and integrity statements
Appropriate Internal Documentation
Style:
No global variables
Code is modular
Appropriate Pre-processing and using directives
Member functions and variables are declared with
appropriate
protection (i.e. private or public)
Three separate files are created for the program: Square.h
(header file), Square.cpp (class implementation file), and
SquareDriver.cpp (driver file)
No unnecessary #include statements
Requirements:
Class Creation
Appropriate data member(s) is(are) declared
Zero argument constructor initializes side to zero
calcPerimeter()
calcArea()
setSide()
getSide()
showData()
Inputs
Prompts user for side with appropriate error checking
Loops until -1 is entered
Object Creation
Square object created correctly
Processing and Outputs
Output is displayed neatly
Page 2 of 2
Over time, inflation raises the cost of goods and services by
eroding each currency's
buying power. It raises one's standard of living expenses.
Inflation in the United States has
eroded the buying power of the dollar. As a result of rising
costs, people's purchasing power
diminishes over time, lowering their quality of life. Inflation is
the rise or fall in prices, expressed
as a percentage, over a certain period, generally a month or a
year. Price increases over that
period were measured using this percentage. The inflation rate
which is a component of the
misery index is an economic statistic that helps to measure a
person's financial well-being and
is crucial. The unemployment rate is also a factor. When the
misery index is over 7%, people
are either in the midst of a recession or are fighting inflation
(Castillo-Martinez, 2019).
Inflation is caused by one of two things. Inflation that is driven
by consumer demand is
by far the most prevalent kind. In this case, the demand for a
product or service is greater than
the supply. Customers are prepared to pay more for the goods
since they need them so badly.
The prices of various goods increase when there is an increase
in demand. The supply of
various products decreases when the demand increases. The
second, less typical reason for
inflation is an increase in the price of goods and services (Bohl,
2018). It is at this point that
supply becomes constrained while demand remains unhindered.
This occurred as a result of
damage to gas supply lines caused by Hurricane Katrina in
2005. The need for gasoline did not
alter, but the lack of supplies resulted in a $5 per gallon price
increase. When there is a
shortage in the supply of various goods, the pressure on prices
increases. Prices of various
commodities are likely to increase because people chase few
goods using a lot of money.
Higher prices are the result of demand surpassing supply. For
example, the prices of products
such as oil have increased in various parts of the world due to
limited supply. Supply shocks
disrupting production can lead to decreases in supply. Examples
of supply shocks are natural
disasters (Taylor, 2019). When there is a disruption in
production, the number of goods that can
be supplied to the customers decreases. This leads to incr eases
in prices creating inflation.
Built-in inflation may also be cited as a third factor. People's
anticipation of future inflation
has a role in this calculation. Increases in salaries are expected
by workers, but also boost the
cost of producing a product. Prices for products and services are
going up again. When these
causes and effects persist, it forms a wage-price spiral. An
increase in production costs can
raise the living costs. As the living cost increases, workers
might start to demand higher wages.
Various factors influence each other and they create a cycle.
Increases in production costs such
as wages and raw materials lead to cost-push inflation. High
production costs lead to a
decrease in the supply of goods. The increased production costs
are passed to the consumers,
and they are forced to pay higher prices for various consumer
products. The prices of raw
materials such as copper might increase. All companies that use
copper as a raw material
would have to increase their prices because of the increased
cost of raw materials.
The Consumer Price Index (CPI) is used by the U.S. Bureau of
Labor Statistics (BLS)
to calculate inflation (Taylor, 2019). A poll of 23,000 firms is
used to compile the index's data. An
80,000-item pricing database is updated every month. The
Consumer Price Index (CPI) will give
you the overall inflation rate. Inflation is also tracked by the
Personal Consumption Expenditures
Price Index. In comparison to the CPI, this index covers a
broader range of commercial products
and services. The consumer price index determines the price
changes of various products and
services.
One can calculate the consumer price index by averaging the
price changes of various items in
the basket of goods. The consumer price index can be used to
determine the purchasing power
of a particular currency. It does not include the investments and
savings of individuals. The
consumer price index is based on an index average that was set
to 100. The increases in
average prices are represented as percentage changes in the
index based on the index
average from a prior period.
Monetary policy is used by central banks all over the globe to
keep inflation and deflation
at bay. Currently, the Federal Reserve in the United States sets
a target inflation rate of 2%
each year. By allowing a goal inflation rate of greater than 2%,
the FOMC said on August 27,
2020, that it will aid in maintaining maximum employment
(Siami-Namini, 2019). The target of
2% inflation remains, but the October 2021 rate shows that it is
ready to accept higher rates if
inflation has remained low for a long period. The Fed uses the
core inflation rate, which
excludes energy and food costs, to measure inflation.
Commodity merchants determine these
prices, which are too volatile to take into account. Monetary
policy refers to the communications
and actions of the central bank to manage the money supply.
Central banks can use monetary
policy to reduce liquidity. They can use tools such as bank
reserve requirements, government
bonds, and interest rates. Central banks can restrict the amount
of money that banks can lend.
When there is inflation, the central banks often take action to
reduce the money supply. Central
banks can increase interest rates when there are significant
increases in prices. They can also
lower interest rates when inflation falls.
Inflation targeting is a strategy used by central banks to
maintain price stability. The
federal reserve can use open market operations to control the
prices of various commodities.
Open market operations are a tool that central banks can use for
monetary policy. The federal
reserve can sell or purchase securities in the market. To
increase the money supply, the federal
reserve purchases securities. It sells them to reduce interest
rates. Open market operations can
be used to control inflation. They can affect interest rates that
also determine the inflation rate.
References (APA)
Bohl, M. T., & Siklos, P. L. (2018). The anatomy of inflation:
An economic history perspective.
Prepared for the Handbook of the History of Money and
Currency (Vienna: Springer), edited by
S. Battilosi, Y. Cassis, and K. Yago, Forthcoming, CAMA
Working Paper, (8).
Castillo-Martinez, L., & Reis, R. (2019). How do central banks
control inflation? A guide for the
perplexed. LSE manuscript.
McLeay, M., & Tenreyro, S. (2020). Optimal inflation and the
identification of the Phillips curve.
NBER Macroeconomics Annual, 34(1), 199-255.
Siami-Namini, S., & Hudson, D. (2019). Inflation and income
inequality in developed and
developing countries. Journal of Economic Studies.
Taylor, J. B. (2019). Inflation targeting in high inflation
emerging economies: Lessons about
rules and instruments. Journal of Applied Economics, 22(1),
103-116.

More Related Content

Similar to C++ Programming Class Creation Program Assignment Instructions

ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationRandy Connolly
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxMalla Reddy University
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPMCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPAli Shah
 
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.docabdulhaq467432
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxfaithxdunce63732
 
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...Amazon Web Services
 
So You Want to Write an Exporter
So You Want to Write an ExporterSo You Want to Write an Exporter
So You Want to Write an ExporterBrian Brazil
 
An Introduction To C++Templates
An Introduction To C++TemplatesAn Introduction To C++Templates
An Introduction To C++TemplatesGanesh Samarthyam
 
C programming session 09
C programming session 09C programming session 09
C programming session 09Dushmanta Nath
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docxhoney725342
 
Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfrajeshjangid1865
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5Mahmoud Ouf
 
(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercises(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercisesNico Ludwig
 

Similar to C++ Programming Class Creation Program Assignment Instructions (20)

Unit 1
Unit  1Unit  1
Unit 1
 
ASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And RepresentationASP.NET 08 - Data Binding And Representation
ASP.NET 08 - Data Binding And Representation
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
Csharp generics
Csharp genericsCsharp generics
Csharp generics
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISPMCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
 
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docxCS 23001 Computer Science II Data Structures & AbstractionPro.docx
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
 
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
Ten Tips And Tricks for Improving Your GraphQL API with AWS AppSync (MOB401) ...
 
Sharbani bhattacharya VB Structures
Sharbani bhattacharya VB StructuresSharbani bhattacharya VB Structures
Sharbani bhattacharya VB Structures
 
Lec1
Lec1Lec1
Lec1
 
Lec1
Lec1Lec1
Lec1
 
So You Want to Write an Exporter
So You Want to Write an ExporterSo You Want to Write an Exporter
So You Want to Write an Exporter
 
An Introduction To C++Templates
An Introduction To C++TemplatesAn Introduction To C++Templates
An Introduction To C++Templates
 
C programming session 09
C programming session 09C programming session 09
C programming session 09
 
Migration from ASP to ASP.NET
Migration from ASP to ASP.NETMigration from ASP to ASP.NET
Migration from ASP to ASP.NET
 
1 Project 2 Introduction - the SeaPort Project seri.docx
1  Project 2 Introduction - the SeaPort Project seri.docx1  Project 2 Introduction - the SeaPort Project seri.docx
1 Project 2 Introduction - the SeaPort Project seri.docx
 
Educational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdfEducational Objectives After successfully completing this assignmen.pdf
Educational Objectives After successfully completing this assignmen.pdf
 
Intake 38 data access 5
Intake 38 data access 5Intake 38 data access 5
Intake 38 data access 5
 
Csharp
CsharpCsharp
Csharp
 
(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercises(3) cpp abstractions more_on_user_defined_types_exercises
(3) cpp abstractions more_on_user_defined_types_exercises
 

More from TawnaDelatorrejs

Childhood Abuse and Delinquency       150 Words Research regarding.docx
Childhood Abuse and Delinquency       150 Words Research regarding.docxChildhood Abuse and Delinquency       150 Words Research regarding.docx
Childhood Abuse and Delinquency       150 Words Research regarding.docxTawnaDelatorrejs
 
Childrens StoryKnowing how to address a variety of situations in .docx
Childrens StoryKnowing how to address a variety of situations in .docxChildrens StoryKnowing how to address a variety of situations in .docx
Childrens StoryKnowing how to address a variety of situations in .docxTawnaDelatorrejs
 
Children build their identities based on what they are exposed to, a.docx
Children build their identities based on what they are exposed to, a.docxChildren build their identities based on what they are exposed to, a.docx
Children build their identities based on what they are exposed to, a.docxTawnaDelatorrejs
 
Child poverty and homelessness are two of the most complex problems .docx
Child poverty and homelessness are two of the most complex problems .docxChild poverty and homelessness are two of the most complex problems .docx
Child poverty and homelessness are two of the most complex problems .docxTawnaDelatorrejs
 
Child abuse and neglect are critical issues inherent in the field of.docx
Child abuse and neglect are critical issues inherent in the field of.docxChild abuse and neglect are critical issues inherent in the field of.docx
Child abuse and neglect are critical issues inherent in the field of.docxTawnaDelatorrejs
 
Check.DescriptionI need help with this one-page essay Please!Co.docx
Check.DescriptionI need help with this one-page essay Please!Co.docxCheck.DescriptionI need help with this one-page essay Please!Co.docx
Check.DescriptionI need help with this one-page essay Please!Co.docxTawnaDelatorrejs
 
Check the paper you write and add your perspective I forgot to say s.docx
Check the paper you write and add your perspective I forgot to say s.docxCheck the paper you write and add your perspective I forgot to say s.docx
Check the paper you write and add your perspective I forgot to say s.docxTawnaDelatorrejs
 
Check out attachments and read instructions before you make Hand Sh.docx
Check out attachments and read instructions before you make Hand Sh.docxCheck out attachments and read instructions before you make Hand Sh.docx
Check out attachments and read instructions before you make Hand Sh.docxTawnaDelatorrejs
 
check out the attachment, it has prompt, use the 4 website to quote .docx
check out the attachment, it has prompt, use the 4 website to quote .docxcheck out the attachment, it has prompt, use the 4 website to quote .docx
check out the attachment, it has prompt, use the 4 website to quote .docxTawnaDelatorrejs
 
Charles Mann is not only interested in how American societies arrive.docx
Charles Mann is not only interested in how American societies arrive.docxCharles Mann is not only interested in how American societies arrive.docx
Charles Mann is not only interested in how American societies arrive.docxTawnaDelatorrejs
 
Check out attachments and read instructions before you make Hand Sha.docx
Check out attachments and read instructions before you make Hand Sha.docxCheck out attachments and read instructions before you make Hand Sha.docx
Check out attachments and read instructions before you make Hand Sha.docxTawnaDelatorrejs
 
Chapters 5-8. One very significant period in Graphic Design History .docx
Chapters 5-8. One very significant period in Graphic Design History .docxChapters 5-8. One very significant period in Graphic Design History .docx
Chapters 5-8. One very significant period in Graphic Design History .docxTawnaDelatorrejs
 
childrens right in Pakistan.6 pagesat least 7 referencesAPA s.docx
childrens right in Pakistan.6 pagesat least 7 referencesAPA s.docxchildrens right in Pakistan.6 pagesat least 7 referencesAPA s.docx
childrens right in Pakistan.6 pagesat least 7 referencesAPA s.docxTawnaDelatorrejs
 
CHAPTER ONEIntroductionLearning Objectives• Be able to concept.docx
CHAPTER ONEIntroductionLearning Objectives• Be able to concept.docxCHAPTER ONEIntroductionLearning Objectives• Be able to concept.docx
CHAPTER ONEIntroductionLearning Objectives• Be able to concept.docxTawnaDelatorrejs
 
Chapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docx
Chapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docxChapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docx
Chapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docxTawnaDelatorrejs
 
Chapter 9 provides a discussion of the challenges of identifying ELL.docx
Chapter 9 provides a discussion of the challenges of identifying ELL.docxChapter 9 provides a discussion of the challenges of identifying ELL.docx
Chapter 9 provides a discussion of the challenges of identifying ELL.docxTawnaDelatorrejs
 
Chapter 8 -- Crimes            1.            Conduct that may be.docx
Chapter 8 -- Crimes            1.            Conduct that may be.docxChapter 8 -- Crimes            1.            Conduct that may be.docx
Chapter 8 -- Crimes            1.            Conduct that may be.docxTawnaDelatorrejs
 
chapter 5 Making recommendations for I studied up to this .docx
chapter 5 Making recommendations for I studied up to this .docxchapter 5 Making recommendations for I studied up to this .docx
chapter 5 Making recommendations for I studied up to this .docxTawnaDelatorrejs
 
Chapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docx
Chapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docxChapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docx
Chapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docxTawnaDelatorrejs
 
Chapter 41. Read in the text about Alexanders attempt to fuse Gre.docx
Chapter 41. Read in the text about Alexanders attempt to fuse Gre.docxChapter 41. Read in the text about Alexanders attempt to fuse Gre.docx
Chapter 41. Read in the text about Alexanders attempt to fuse Gre.docxTawnaDelatorrejs
 

More from TawnaDelatorrejs (20)

Childhood Abuse and Delinquency       150 Words Research regarding.docx
Childhood Abuse and Delinquency       150 Words Research regarding.docxChildhood Abuse and Delinquency       150 Words Research regarding.docx
Childhood Abuse and Delinquency       150 Words Research regarding.docx
 
Childrens StoryKnowing how to address a variety of situations in .docx
Childrens StoryKnowing how to address a variety of situations in .docxChildrens StoryKnowing how to address a variety of situations in .docx
Childrens StoryKnowing how to address a variety of situations in .docx
 
Children build their identities based on what they are exposed to, a.docx
Children build their identities based on what they are exposed to, a.docxChildren build their identities based on what they are exposed to, a.docx
Children build their identities based on what they are exposed to, a.docx
 
Child poverty and homelessness are two of the most complex problems .docx
Child poverty and homelessness are two of the most complex problems .docxChild poverty and homelessness are two of the most complex problems .docx
Child poverty and homelessness are two of the most complex problems .docx
 
Child abuse and neglect are critical issues inherent in the field of.docx
Child abuse and neglect are critical issues inherent in the field of.docxChild abuse and neglect are critical issues inherent in the field of.docx
Child abuse and neglect are critical issues inherent in the field of.docx
 
Check.DescriptionI need help with this one-page essay Please!Co.docx
Check.DescriptionI need help with this one-page essay Please!Co.docxCheck.DescriptionI need help with this one-page essay Please!Co.docx
Check.DescriptionI need help with this one-page essay Please!Co.docx
 
Check the paper you write and add your perspective I forgot to say s.docx
Check the paper you write and add your perspective I forgot to say s.docxCheck the paper you write and add your perspective I forgot to say s.docx
Check the paper you write and add your perspective I forgot to say s.docx
 
Check out attachments and read instructions before you make Hand Sh.docx
Check out attachments and read instructions before you make Hand Sh.docxCheck out attachments and read instructions before you make Hand Sh.docx
Check out attachments and read instructions before you make Hand Sh.docx
 
check out the attachment, it has prompt, use the 4 website to quote .docx
check out the attachment, it has prompt, use the 4 website to quote .docxcheck out the attachment, it has prompt, use the 4 website to quote .docx
check out the attachment, it has prompt, use the 4 website to quote .docx
 
Charles Mann is not only interested in how American societies arrive.docx
Charles Mann is not only interested in how American societies arrive.docxCharles Mann is not only interested in how American societies arrive.docx
Charles Mann is not only interested in how American societies arrive.docx
 
Check out attachments and read instructions before you make Hand Sha.docx
Check out attachments and read instructions before you make Hand Sha.docxCheck out attachments and read instructions before you make Hand Sha.docx
Check out attachments and read instructions before you make Hand Sha.docx
 
Chapters 5-8. One very significant period in Graphic Design History .docx
Chapters 5-8. One very significant period in Graphic Design History .docxChapters 5-8. One very significant period in Graphic Design History .docx
Chapters 5-8. One very significant period in Graphic Design History .docx
 
childrens right in Pakistan.6 pagesat least 7 referencesAPA s.docx
childrens right in Pakistan.6 pagesat least 7 referencesAPA s.docxchildrens right in Pakistan.6 pagesat least 7 referencesAPA s.docx
childrens right in Pakistan.6 pagesat least 7 referencesAPA s.docx
 
CHAPTER ONEIntroductionLearning Objectives• Be able to concept.docx
CHAPTER ONEIntroductionLearning Objectives• Be able to concept.docxCHAPTER ONEIntroductionLearning Objectives• Be able to concept.docx
CHAPTER ONEIntroductionLearning Objectives• Be able to concept.docx
 
Chapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docx
Chapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docxChapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docx
Chapter TenThe Federal JudiciaryBrian M. MurphyLearnin.docx
 
Chapter 9 provides a discussion of the challenges of identifying ELL.docx
Chapter 9 provides a discussion of the challenges of identifying ELL.docxChapter 9 provides a discussion of the challenges of identifying ELL.docx
Chapter 9 provides a discussion of the challenges of identifying ELL.docx
 
Chapter 8 -- Crimes            1.            Conduct that may be.docx
Chapter 8 -- Crimes            1.            Conduct that may be.docxChapter 8 -- Crimes            1.            Conduct that may be.docx
Chapter 8 -- Crimes            1.            Conduct that may be.docx
 
chapter 5 Making recommendations for I studied up to this .docx
chapter 5 Making recommendations for I studied up to this .docxchapter 5 Making recommendations for I studied up to this .docx
chapter 5 Making recommendations for I studied up to this .docx
 
Chapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docx
Chapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docxChapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docx
Chapter 4. Terris, Daniel. (2005) Ethics at Work Creating Virtue at.docx
 
Chapter 41. Read in the text about Alexanders attempt to fuse Gre.docx
Chapter 41. Read in the text about Alexanders attempt to fuse Gre.docxChapter 41. Read in the text about Alexanders attempt to fuse Gre.docx
Chapter 41. Read in the text about Alexanders attempt to fuse Gre.docx
 

Recently uploaded

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 

Recently uploaded (20)

Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 

C++ Programming Class Creation Program Assignment Instructions

  • 1. C++ Programming: Class Creation Program Assignment Instructions Overview The purpose of this assignment is to give you some practice with creating your own classes. This program serves as the basis for all of the other programming assignments in this class and your future Computer Science classes. Instructions Construct a class named Square that has a floating-point data member named side. The class should have a zero-argument constructor that initializes this data member to 0. It should have member functions named calcPerimeter() and calcArea() that calculate the perimeter and area of a square respectively, a member function setSide() to set the side of the square, a member function getSide() to return the side, and a member function showData() that displays the square’s side, perimeter, and area. The formula for the area of a square is Area = side * side. The formula for the perimeter of a square is Perimeter = 4 * side. The class should use appropriate protection levels for the member data and functions. It should also follow “principles of minimalization”: that is, no member data should be part of a class unless it is needed by most member functions of the object. A general rule of thumb is that “if you can easily calculate it, don’t store it.” Use your class in a program that creates an instance of a Square (utilizing the zero-argument constructor), prompts a user for a side, calls the setSide() function to set the square’s side, and then calls showData() to display the square’s side, perimeter, and area. Your program should allow the user to enter new square dimensions until the user enters -1. Be sure to include appropriate error checking. Does it make sense to enter “abc”
  • 2. as the side of a square? No. Therefore, you should ensure that the user enters numeric data for the side. Negative numbers (other than the -1 to exit) should also be prevented. Style: · Your lab should be constructed such that separate files are used: Square.h (your class declaration file), Square.cpp (your class implementation file), and SquareDriver.cpp (the file that contains main() and any other functions that are not part of the class). The purpose of having separate files is for code resusability. If other developers want to use your class in their programs, they don't need main() as well. They should only have to "#include" your class header file. As such, two separate files for the class are needed to be able to hide the implementation details from other developers. You want other developers to know how to use your class (i.e. what functions are available and how they are called -- this is called the "interface" of the class), but not how they are implemented. If both the interface and the implementation code are in the same file, this cannot be accomplished. When you distribute your class to other developers, the implementation (.cpp) file gets compiled, but the interface (.h) doesn't. That way, the developer can use your class, but he or she can't see or change your code in your class functions. · Never use “using namespace std;” in a header file. Here is a link that describes why: https://stackoverflow.com/questions/14575799/using- namespace-std-in-a-header-file · Note that when you follow the rule above and don’t use “using namespace std;” in a header file, you have to remember to prefix certain things with std:: (i.e. cout, cin, endl, string, istream, ostream, and vector). If you fail to prefix these words with std::, you will get a compilation error that is often quite cryptic. Be on the lookout for this situation. It may save you hours of debugging.
  • 3. · All "get" functions should be declared as constant. In fact, any function that does not change the data in the data members should be declared as constant. This is a security measure that prevents anyone from accidentally writing code in a function that changes underlying data when the purpose of the function is only to retrieve the data. In other words, "const" at the end of a function provides protection of your data. The rationale is that certain functions (e.g. those that merely return a data item to the caller or even those that just print the data) should be prevented from ever changing the underlying data. If a function doesn't need "write" access to a data item, it shouldn't be granted the access. This adheres to the “Principle of Least Privilege,” which is a security principle that helps to protect the integrity of your data. One other thing that's important to know for future reference: Whenever you make a function constant, it can't call another function unless that function is also constant. It makes sense that if you lock down an object in a function, you don't want to open it up for modifications by calling another function that allows it to be inadvertently altered. If you ever try to call a function that is not constant from a function that is constant, you will get a compilation error. · showData() should not refer to the data members directly. Instead, it should call getSide() to retrieve its value. Think of your getters and setters as middlemen. You should try to avoid accessing your data members directly due to maintenance issues. Pretend that you decided to change the name of your side variable to be "sid". You really should only have to make that change in two functions: getSide and setSide. If you refer to the private data members directly throughout your code, you'll have a nightmare trying to make all the changes necessary. If you always use the getters to retrieve your data, any changes you make to the variable name will only necessitate changes to your get function rather than your whole code base.
  • 4. · CalcPerimeter, CalcArea, and ShowData should not have the side passed in as an argument because side is a data member of the class. Class functions have direct access to all data members in their own class. By passing in an argument for the value of the side, you're not using the value that has already been stored in the data member. You're using the value that you've passed in to the functions, which circumvents the whole purpose of storing side in the class. · Use good prompting (correct spelling and clear instructions), output labeling, and modularization in your program and class. · Be sure to avoid using global variables in your program unless they are constants. · Finally, be sure not to include any unnecessary libraries. Deliverables: · Complete the programming assignment described above and submit your completed assignment in accordance with the assignment submission policies. To give you an idea of the general criteria that will be used for grading, here is a checklist that you might find helpful: Compiles and Executes without crashing Word document contains screen shots and integrity statements Appropriate Internal Documentation Style: No global variables Code is modular Appropriate Pre-processing and using directives Member functions and variables are declared with appropriate protection (i.e. private or public)
  • 5. Three separate files are created for the program: Square.h (header file), Square.cpp (class implementation file), and SquareDriver.cpp (driver file) No unnecessary #include statements Requirements: Class Creation Appropriate data member(s) is(are) declared Zero argument constructor initializes side to zero calcPerimeter() calcArea() setSide() getSide() showData() Inputs Prompts user for side with appropriate error checking Loops until -1 is entered Object Creation Square object created correctly Processing and Outputs Output is displayed neatly Page 2 of 2 Over time, inflation raises the cost of goods and services by eroding each currency's buying power. It raises one's standard of living expenses. Inflation in the United States has eroded the buying power of the dollar. As a result of rising costs, people's purchasing power
  • 6. diminishes over time, lowering their quality of life. Inflation is the rise or fall in prices, expressed as a percentage, over a certain period, generally a month or a year. Price increases over that period were measured using this percentage. The inflation rate which is a component of the misery index is an economic statistic that helps to measure a person's financial well-being and is crucial. The unemployment rate is also a factor. When the misery index is over 7%, people are either in the midst of a recession or are fighting inflation (Castillo-Martinez, 2019). Inflation is caused by one of two things. Inflation that is driven by consumer demand is by far the most prevalent kind. In this case, the demand for a product or service is greater than the supply. Customers are prepared to pay more for the goods since they need them so badly. The prices of various goods increase when there is an increase in demand. The supply of various products decreases when the demand increases. The second, less typical reason for inflation is an increase in the price of goods and services (Bohl, 2018). It is at this point that
  • 7. supply becomes constrained while demand remains unhindered. This occurred as a result of damage to gas supply lines caused by Hurricane Katrina in 2005. The need for gasoline did not alter, but the lack of supplies resulted in a $5 per gallon price increase. When there is a shortage in the supply of various goods, the pressure on prices increases. Prices of various commodities are likely to increase because people chase few goods using a lot of money. Higher prices are the result of demand surpassing supply. For example, the prices of products such as oil have increased in various parts of the world due to limited supply. Supply shocks disrupting production can lead to decreases in supply. Examples of supply shocks are natural disasters (Taylor, 2019). When there is a disruption in production, the number of goods that can be supplied to the customers decreases. This leads to incr eases in prices creating inflation. Built-in inflation may also be cited as a third factor. People's anticipation of future inflation has a role in this calculation. Increases in salaries are expected
  • 8. by workers, but also boost the cost of producing a product. Prices for products and services are going up again. When these causes and effects persist, it forms a wage-price spiral. An increase in production costs can raise the living costs. As the living cost increases, workers might start to demand higher wages. Various factors influence each other and they create a cycle. Increases in production costs such as wages and raw materials lead to cost-push inflation. High production costs lead to a decrease in the supply of goods. The increased production costs are passed to the consumers, and they are forced to pay higher prices for various consumer products. The prices of raw materials such as copper might increase. All companies that use copper as a raw material would have to increase their prices because of the increased cost of raw materials. The Consumer Price Index (CPI) is used by the U.S. Bureau of Labor Statistics (BLS) to calculate inflation (Taylor, 2019). A poll of 23,000 firms is used to compile the index's data. An 80,000-item pricing database is updated every month. The
  • 9. Consumer Price Index (CPI) will give you the overall inflation rate. Inflation is also tracked by the Personal Consumption Expenditures Price Index. In comparison to the CPI, this index covers a broader range of commercial products and services. The consumer price index determines the price changes of various products and services. One can calculate the consumer price index by averaging the price changes of various items in the basket of goods. The consumer price index can be used to determine the purchasing power of a particular currency. It does not include the investments and savings of individuals. The consumer price index is based on an index average that was set to 100. The increases in average prices are represented as percentage changes in the index based on the index average from a prior period. Monetary policy is used by central banks all over the globe to keep inflation and deflation at bay. Currently, the Federal Reserve in the United States sets
  • 10. a target inflation rate of 2% each year. By allowing a goal inflation rate of greater than 2%, the FOMC said on August 27, 2020, that it will aid in maintaining maximum employment (Siami-Namini, 2019). The target of 2% inflation remains, but the October 2021 rate shows that it is ready to accept higher rates if inflation has remained low for a long period. The Fed uses the core inflation rate, which excludes energy and food costs, to measure inflation. Commodity merchants determine these prices, which are too volatile to take into account. Monetary policy refers to the communications and actions of the central bank to manage the money supply. Central banks can use monetary policy to reduce liquidity. They can use tools such as bank reserve requirements, government bonds, and interest rates. Central banks can restrict the amount of money that banks can lend. When there is inflation, the central banks often take action to reduce the money supply. Central banks can increase interest rates when there are significant increases in prices. They can also lower interest rates when inflation falls.
  • 11. Inflation targeting is a strategy used by central banks to maintain price stability. The federal reserve can use open market operations to control the prices of various commodities. Open market operations are a tool that central banks can use for monetary policy. The federal reserve can sell or purchase securities in the market. To increase the money supply, the federal reserve purchases securities. It sells them to reduce interest rates. Open market operations can be used to control inflation. They can affect interest rates that also determine the inflation rate. References (APA) Bohl, M. T., & Siklos, P. L. (2018). The anatomy of inflation: An economic history perspective. Prepared for the Handbook of the History of Money and Currency (Vienna: Springer), edited by S. Battilosi, Y. Cassis, and K. Yago, Forthcoming, CAMA Working Paper, (8). Castillo-Martinez, L., & Reis, R. (2019). How do central banks control inflation? A guide for the perplexed. LSE manuscript.
  • 12. McLeay, M., & Tenreyro, S. (2020). Optimal inflation and the identification of the Phillips curve. NBER Macroeconomics Annual, 34(1), 199-255. Siami-Namini, S., & Hudson, D. (2019). Inflation and income inequality in developed and developing countries. Journal of Economic Studies. Taylor, J. B. (2019). Inflation targeting in high inflation emerging economies: Lessons about rules and instruments. Journal of Applied Economics, 22(1), 103-116.