Question: Main Program #9, due Thurs 4/13/17 by 11pm on Titanium Write a class named Purchase and a main program to test the class. The details

 Main Program #9, due Thurs 4/13/17 by 11pm on Titanium Write
a class named Purchase and a main program to test the class.
Main
The details for each are listed below Note: the names in bold

Program #9, due Thurs 4/13/17 by 11pm on Titanium Write a class named Purchase and a main program to test the class. The details for each are listed below Note: the names in bold indicate names that you must use in your code in order for it to work with the main program that will be used for testing your programs. Purchase class Private data: An integer for the number of items being purchased A double for the price per item for the thing(s) being bought. A double for the calculated cost for these items (number of items x item price) An integer for the purchase number (each object will have a different number). A static integer variable to count how many Purchase objects have been created. This should be initialized to 0 Public functions Note on constructors: you can write the two constructors separately as described here or you may combine them together using default parameter values so that both versions are available, but only one definition is needed. Default constructor should set number of items, item price, and cost all to 0. Should increment the static count variable and assign the new value to the purchase number field Non-default constructor will receive an integer for number of items and a double for item price. Should make sure that number of items is a non-negative value. Ifthe parameter is non-negative, then copy it to the private data field. Should make sure that item price has no more than 2 decimal places of accuracy (to be a money value). If there are 2 or less decimal places of accuracy, copy the value to the private data field. Should call the object's private calculate function to calculate the cost field. Should increment the static count variable and assign the new value to the purchase number field Destructor should write out "destroying purchase H" followed by the value from the object's purchase number field setNumitems-will receive an integer for number of items. Should make sure that number of items is a non-negative value. If the parameter is non-negative, then copy it to the private data field setltemPrice will receive a double for item price. Should make sure that item price has no more than 2 decimal places of accuracy (to be a money value). If there are 2 or less decimal places of accuracy, copy the value to the private data field getNumltems return a copy of the number of items field. getitemPrice return a copy of the item price field. print-writes out the object's data in a format like that shown in the sample run

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!