SlideShare a Scribd company logo
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 (20)

PPT
Express 070 536
chokkamedex
 
PPTX
Unit 1
donny101
 
PPT
ASP.NET 08 - Data Binding And Representation
Randy Connolly
 
PPTX
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Malla Reddy University
 
DOCX
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
Ali Shah
 
PDF
OOPs theory about its concepts and properties.
ssuser1af273
 
DOC
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
abdulhaq467432
 
PPTX
PL-400T00A-ENU-PowerPoint_01.pptx- Power Platform
Blacklight28
 
DOCX
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
faithxdunce63732
 
PPTX
object oriented programming language in c++
Ravikant517175
 
PPTX
Sharbani bhattacharya VB Structures
Sharbani Bhattacharya
 
PPT
Lec1
Saad Gabr
 
PPTX
So You Want to Write an Exporter
Brian Brazil
 
PDF
An Introduction To C++Templates
Ganesh Samarthyam
 
PPTX
C++ tutorial assignment - 23MTS5730.pptx
sp1312004
 
PPS
C programming session 09
Dushmanta Nath
 
PPTX
Some more Concepts of DOT cvcvcvNET.pptx
zmulani8
 
PPT
Migration from ASP to ASP.NET
Information Technology
 
Express 070 536
chokkamedex
 
Unit 1
donny101
 
ASP.NET 08 - Data Binding And Representation
Randy Connolly
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Malla Reddy University
 
MCS,BCS-7(A,B) Visual programming Syllabus for Final exams @ ISP
Ali Shah
 
OOPs theory about its concepts and properties.
ssuser1af273
 
7.-Download_CS201-Solved-Subjective-with-Reference-by-Aqib.doc
abdulhaq467432
 
PL-400T00A-ENU-PowerPoint_01.pptx- Power Platform
Blacklight28
 
CS 23001 Computer Science II Data Structures & AbstractionPro.docx
faithxdunce63732
 
object oriented programming language in c++
Ravikant517175
 
Sharbani bhattacharya VB Structures
Sharbani Bhattacharya
 
Lec1
Saad Gabr
 
So You Want to Write an Exporter
Brian Brazil
 
An Introduction To C++Templates
Ganesh Samarthyam
 
C++ tutorial assignment - 23MTS5730.pptx
sp1312004
 
C programming session 09
Dushmanta Nath
 
Some more Concepts of DOT cvcvcvNET.pptx
zmulani8
 
Migration from ASP to ASP.NET
Information Technology
 

More from TawnaDelatorrejs (20)

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

Recently uploaded (20)

PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PPTX
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
PPTX
Presentation: Climate Citizenship Digital Education
Karl Donert
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
PPTX
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
PPTX
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PDF
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
PPTX
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
PPTX
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
Presentation: Climate Citizenship Digital Education
Karl Donert
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
How to Create Rental Orders in Odoo 18 Rental
Celine George
 
Optimizing Cancer Screening With MCED Technologies: From Science to Practical...
i3 Health
 
Nutri-QUIZ-Bee-Elementary.pptx...................
ferdinandsanbuenaven
 
community health nursing question paper 2.pdf
Prince kumar
 
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPT on the Development of Education in the Victorian England
Beena E S
 
The-Beginnings-of-Indian-Civilisation.pdf/6th class new ncert social/by k san...
Sandeep Swamy
 
HEAD INJURY IN CHILDREN: NURSING MANAGEMENGT.pptx
PRADEEP ABOTHU
 
Explorando Recursos do Summer '25: Dicas Essenciais - 02
Mauricio Alexandre Silva
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
How to Configure Prepayments in Odoo 18 Sales
Celine George
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
Ad

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.