I'm supposed to write a program with the following information, but I'm not exactully sure how because of poor examples from my source books. im supposed to use loops
You will have 3 functions in addition to the main function
Get_list will print the list for the user and get the input from the user
Total_cost will calculate the total cost of the items
Take_money will print the bill, get the debit input from the user and print the change. Use an error trap so that a debit of more than $20.00 over the bill or a debit less than the bill will not be accepted.
You will need to use the following constants
MILKPRICE = 1.37
EGGPRICE = 1.29
BREADPRICE = .88
Code:
Here is your main function. You must use this in your program - do not change it.
//=============================main=============
int main()
{ int eggs, milk, bread;// entered by user
float bill;// calculated
Get_list(eggs, milk, bread);
bill = Total_cost(eggs,milk,bread);
Take_money(bill);
return 0;
}// end main
****edit***opps, sorry...i forgot to add what i had come up with so far. i'm sorry, i wouldn't want to do someone one elses homework either**
Code:
#include <iostream.h>
//=============================main========================
int main()
{ int eggs, milk, bread;// entered by user
float bill;// calculated
egg=milk=bread=0;
bill= 0.0;
Get_list(eggs, milk, bread);
bill = Total_cost(eggs,milk,bread);
Take_money(bill);
return 0;
}// end main
const double MILKPRICE = 1.37, EGGPRICE = 1.29, BREADPRICE = 0.88
///==================Get_list=========
void Get_list()
{
cout<< " Please enter the number or items you would like"<<endl;
cout<< " How many quarts of milk @ $1.37 : "<<endl;
cin>> milk;
cout<< " How many dozens of eggs @ $1.29 : "<<endl;
cin >> eggs;
cout<< " How many loaves of bread @ $0.88 : " << endl;
cin >> bread;
} //end get_list
//==========Total_cost==========
{
Total_cost= MILKPRICE * milk + EGGPRICE * eggs + BREADPRICE * bread
} // end Total_cost
//==========Take_money=====
{
cout<<"Your total bill is: "<<bill<<endl;
cout<<"Please enter the amount you want debited:"<<endl;
cin>>Take_money;
if(Take_money >50)
{
cout<<"Sorry, you have a limit of $20.00 over your bill." << endl;
cout<< Your maimum debit can be" << bill + 20<< endl;
cout<< "Please reenter your debit amount:<<endl;
}
}//end Take_money