need help

Betty's Bagelry charges $3.80 for a baker's dozen of bagels (13 bagels). The price for half a dozen (6 bagels) is $2.60. A single bagel costs $ .50. Betty is an honest merchant. Customers always get the best price on an order, even if they get more bagels than ordered. For example, a customer that orders 10 bagels would pay $4.60 (2.60 for a half dozen bagels plus $2.00 for 4 single bagels. Betty gives her customers 13 bagels, saving the customer $.80.



Write a C++ program that will help Betty help her customers. Your program prompts the user for the number of bagels. If then calculates the customers payment two ways. First it finds the price of the smallest multiple of 13 bagels that is closest to the customer's order. It then calculates the price of the customer's order so that the customer's payment is the smallest amount possible with the customer getting the exact number of bagels ordered. If the first method is the smallest amount the program outputs the number of bagels the customer will receive along with the dollar amount owed, and the dollar amount saved. Otherwise just print the number of bagels received and the dollar amount owed.



Print all dollar amounts to two decimal spaces.



Test your program on the following inputs and two of your own. Make sure you test for all logical possibilities.



10 bagels

24 bagels

13 bagels

14 bagels



Sample output:



How many bagels would you like today? 10

Thank you for your order.

You will receive 13 bagels instead of 10 for a savings of $0.80.

Please pay the cashier $3.80

Press any key to continue



How many bagels would you like today? 24

Thank you for your order.

You will receive 26 bagels instead of 24 for a savings of $1.30.

Please pay the cashier $7.60

Press any key to continue



How many bagels would you like today? 13

Thank you for your order. Please pay the cashier $3.80

Press any key to continue



How many bagels would you like today? 14

Thank you for your order. Please pay the cashier $4.30

Press any key to continue



my code
#include<iostream>
using namespace std;
int main()
{
double bakers=3.80, half=2.60, single=0.50;
int bagels;
cout<<"how many bagels would you like?"<<endl;
cin>>bagels;

cout<<"total="<<(bagels)*(single)<<endl;
if (bagels>13)
cout<<"You should buy the bakers dozen for a savings of\t"<<(bagels*single)-(bakers)<<endl;
else if(bagels>6)
cout<<"you should buy a half dozen for a savings\t"<<(bagels*single)-(half)<<endl;


return 0;
}

i dont know how to make it say you will get 26 bagels instead of 24 for example.
[3063 byte] By [jj71787] at [2007-11-20 10:50:08]
# 1 Re: need help
[ Moved thread ]
ovidiucucu at 2007-11-9 1:24:42 >
# 2 Re: need help
so far i have this

//john meinke
//sept 5, 2007

#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
double bakers=3.80, half=2.60, single=0.50,cost=0;
int bagels;
cout<<"how many bagels would you like?"<<endl;
cin>>bagels;

cout<<"total="<<(bagels)*(single)<<endl;

cout<<"total="<<(bagels)*(single)<<endl;

if (bagels>13)
{
cost = bagels*0.5;
if(cost > bakers)
cout<<"You should buy the bakers dozen for a savings of.."<<cost-bakers <<endl;
else
cout << "you need to pay " << cost << " for the " << bagels << " you want ";
}
else if(bagels>6)
{
cost = 2.60; // since we already know they got at least 6 so we need to find out the extra
// using mod operator and find cost of extra and add on to totalcost
int extrabagels = bagels % 6;

cost = cost + (extrabagels*0.5);
if(cost > bakers)
cout<<"you should buy a bakers dozen for a savings.."<<cost-bakers<<endl;
else
cout << "you need to pay " << cost << " for the " << bagels << " you want ";
}

return 0;
}
jj71787 at 2007-11-9 1:25:38 >