Write a program that asks the user for the number of bolts, nuts, and washers in their purchase and then calculates and prints out the total. As an added feature, the program checks the order. It is usually a mistake if there are more bolts than nuts. In this case the program writes out "Check the Order." Otherwise the program writes out "Order is OK." In either case the total price is written out. Use constants for the unit cost of each item.
I know I should use loops, but I have no clue as to where I should start.
Well... You'll need to start by finding out what your variables should be.
You have bolts, nuts and washers (what kind of variables would these be? what should they be initialized to?).
You'll have to ask the user to input the amounts of bolts, nuts and washers.
if there are more bolts than nuts,
the program should print "Check the Order." and print the total
if there are an equal amount, or more nuts than bolts,
program prints "Order is OK." and prints the total.
Edited, after re-reading this it doesn't ask you to have the customer re-enter the amounts if there are more bolts than nuts. I don't see any need for a loop at all.
Try writing each line out as code and see what you get.
My code so far, how do I assign prices and add the total up?
int bolts;
int nuts;
int washers;
int cost(bolts+washers+nuts);
cout << "Welcome to Bob Nut's and Bolt's shop!" << endl;
cout << "Please enter the amount of nuts you would like: " << endl;
cin >> nuts;
cout << "Please enter the number of bolts you would like: " << endl;
cin >> bolts;
cout << "Please enter the number of washers you would like: " << endl;
cin >> washers;
cout << "The total cost is:" << cost << endl;
if (bolts>nuts)
{
cout <<"Check the order"<< endl;
cout <<"Please enter the number of bolts again"<< endl;
cin >> bolts ;
}
else
{
cout <<"Order is OK!" << endl;
cout <<"The total is:" << cost << endl;
}