Write a program to create a customer bill for a shop The pro

Write a program to create a customer bill for a shop. The program should prompt the user to enter the number of watches, shoes and Shirt which the customer has purchased. The unit cost of watch is 90 KD, shoe is 20 KD and Shirt is 15 KD You have to use three separate functions as watch(), shoe() and shirt() to calculate each item cost. It then requires to call in main function to print the total price for the customer to pay.

Solution

#include <iostream>

using namespace std;

//Separate function to calculate each item cost for watch
int watch()
{
return 90;
}
//Separate function to calculate each item cost for shoe
int shoe()
{
return 20;
}
//Separate function to calculate each item cost for shirt
int shirt()
{
return 15;
}

int main()
{
long int Watch,Shoe,Shirt; //variables for QTY for watch,shoe and shirt
long int tot_cost_watch,tot_cost_shoe,tot_cost_shirt; //variables for total Cost of each item

cout<<\"Enter the number of watches purchased: \";
cin>>Watch;

cout<<\"Enter the number of shoes purchased: \";
cin>>Shoe;

cout<<\"Enter the number of shirts purchased: \";
cin>>Shirt;
cout<<endl<<endl;


/*
Total Cost (Cost (KD) column) will be
Total Cost = QTY * (Unit Price)
*/

tot_cost_watch = Watch * watch();
tot_cost_shoe = Shoe * shoe();
tot_cost_shirt = Shirt * shirt();

cout<<\"Item \\t QTY \\t Unit Price(KD) \\t Cost(KD) \"<<endl;
cout<<\"---- \\t --- \\t -------------- \\t -------- \"<<endl;
cout<<\"Watch \\t\"<<Watch<<\" \\t\"<<watch()<<\"\\t\\t\\t\"<<tot_cost_watch<<endl;
cout<<\"Shoe \\t\"<<Shoe<<\" \\t\"<<shoe()<<\" \\t\\t\\t\"<<tot_cost_shoe<<endl;
cout<<\"Shirt \\t\"<<Shirt<<\" \\t\"<<shirt()<<\"\\t\\t\\t\"<<tot_cost_shirt<<endl;
cout<<endl;

/*
Total Price will be
Total Price = Total Cost of Watch + Total Cost of Shoes + Total Cost of Shirt
*/
cout<<\"Total Price : \"<<tot_cost_watch+tot_cost_shoe+tot_cost_shirt<<\" KD\"<<endl;
return 0;
}

 Write a program to create a customer bill for a shop. The program should prompt the user to enter the number of watches, shoes and Shirt which the customer has
 Write a program to create a customer bill for a shop. The program should prompt the user to enter the number of watches, shoes and Shirt which the customer has

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site