The tools Hal’s sells are: Hammers: $10.99 Wrenches: $10.99 Levels: $19.99 Tape Measures: $4.99 Screwdrivers: $8.99
In order to make things easier in the long run you have decided to make a c++ program that takes in all the orders for each register and tallies them at the end of the day.
Write a c++ program that does the following:
Create a Register class that can store all of the receipts for the day and the totals for that register.
This class could have the following member functions:
Contructor(int) – Creates a number of receipts based on an integer that is passed into the constructor (this is the largest number of orders that the register can take). You may also be required to create additional variables to make the program work but that’s up to you to determine.
void getorder() – Asks the user how many of each item they want an stores that in the first available receipt.
void returnreceipts() – This function returns the details of all the receipts and the total for the day.
Register operator+(const Register &right)- This is an overloaded addition operator. When two objects are added together an empty temporary register is created (with 0 receipts) and only the totals of both objects are added to it. The temporary register is returned by the function.
Register operator=(const Register &right)- This overloaded assignment operator copies only the totals from the Object on the right.
In the Main function I would like:
Create 3 Register Objects. The first two registers are the ones in the store and should be initialized to take 10 orders. The third is used at closing time and can be initialized with 0 receipts as it will only take in the totals from the other registers.
Run the getorder function for registers 1 and 2 twice.
Run returnreceipts for register 1 and register2.
Reg3=Reg1+Reg2;
Run returnreceipts for register 3.
#include <iostream>
#include <iomanip>
using namespace std;
class Register
{
public:
void returnreceipts();
void getorder();
Register(int numReceipt)
{
numReceipt = reciept;
};
Register operator+(const Register &right); //two objects are added, an empty reg is created (0 receitps)
//only the totals are added. temp reg is returned by the function
Register operator=(const Register &right); //copies only the totals fom te object on the right
};
int main()
{
Register reg1(2),reg2(2),reg3;
cout << "Welcome to Hardware SuperStore! I see we have a number of customers! There are two cash registers available\n" << endl;
reg1.getorder();
reg2.getorder();
return 0;
}
void Register::getorder()
{
int W,S,L,TM,H;
for ( int i = 0; i < 2; i++)
{
cout << "\n";
cout << "How many of each item do you want to order for order no." << i + 1 << "in cash register 1 "<< endl;
cout << "Wrenches: ";
cin >> W;
cout << endl << "Screwdrivers: ";
cin >> S;
cout << endl << "Levels: ";
cin >> L;
cout << endl << "Tape Measures: ";
cin >> TM;
cout << endl << "Hammers: ";
cin >> H;
}
}
this is what I have so far I'm trying to get the input part working first, so the user would be asked each item individual how many they want? this will happen for 2 users, then the next register will do the same? any tips will help