Question
Foundations Of Computer Science Type Answer In C++ ONLY You should NEVER use global variables. Other than the main() function, there should be no global
Foundations Of Computer Science
Type Answer In C++ ONLY
You should NEVER use global variables. Other than the main() function, there should be no global functions in your code. Other than the test() function not other function needs to be a static function in this problem.
Let us say you find a consulting opportunity for a regional real-estate company that wants you to write a class to do statistical analysis that also keeps track of all the houses sold in your area. There are currently 100 houses in the region of their operation and they are never are expected to store more than 200 sales.
They want you to store the sales price in a local array of this class as soon as the house is sold. Only sale price is stored, the address or the date of sale or any other data is not stored by this class.
They also want to be able to calculate the average price of all the houses sold based on the current entries in this array.
You have to write a class that provided following functions:
void addHouseSale(double salePrice); //Adds the house sale to the sales[] array.
double calculateAveragePrice();
The class must implement an array called "sales". You will determine the capacity of the array need in your program and what you need to maintain how many houses have been sold so far.
(You have to make the decision on how many data members you need in addition array. No! this problem does not need dynamic memory allocation).
Your program will assume that the history is started fresh, every time you execute the program. That is: the first call to addHouseSale(double salePrice) will make the first entry into the array.
Please implement a print() function that prints all of the data members of the class in a friendly manner.
Please implement a static test() function that tests all other functions, and at least 5 new entries into the array.
Please make sure that you use "Preformatted" style rather than "Paragraph" for the entire code and ensure it is readable and properly indented.
You have to provide:
You are not required to show code separated by files. You can paste all of your code in the following edit box (using "Preformatted" style).
complete contents of the .h file: [18]
all system includes [1]
all #define's you need [1]
class declaration that includes:
Constructor [2]
all function declarations (including test, and print functions) [8]
the array declaration [4]
any other variables you need to make this work [2]
complete contents of the .cpp file that includes complete definitions (implementation) of: [57]
Constructor
addHouseSale(double salePrice) function [5 points]
calculateAveragePrice() function [20 points]
print() function [10 points]
test() function [20 points]
main function that simply calls the test() function. [2 points]
PROGRAMMABLE MICROCONTROLLERS WITH APPLICATIONS MSP430 LaunchPad with CCS and Grace Mc Graw Hill IED CEM UNSALAN H. DENIZ GRHAN and
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started