this is my instructions
"You have been hired by a local coffee shop to implement an idea the owner is sure will become the next greatest way to order a coffee drink. Rather than customers choosing a drink size based on pre-determined cup sizes, the owner would like for the customer to be able to order any amount of coffee they wish. In order to hold down costs, the employees need to use the fewest cups possible when they fill an order. The cup sizes are Shot (1 oz), Regular (8 oz), Grande (16 oz) and Venti (24 oz)."
and here is a sample output
Enter the amount of coffee in ounces: 57
Enter the name of the customer: Harry Potter
Harry Potter
57 oz
Cups Size Number Needed
-------------- ---------------------
Venti 2
Grande 0
Regular 1
Shot 1
so th crazy part is i cant use if statments, functions, switch statments, or loops (yeah wtf)...... thats what i have so far.. I really really need help to figure this out please..
#include<iostream>
#include<iomanip>
usingnamespace std;
int main(){
int CustmerIN;
string CustmerName;
int Answere;
int Shot = 1;
int Regular = 8;
int Grande = 16;
int Venti = 24;
cout << "Enter the amount of coffee in ounces:";
cin >> CustmerIN;
cin.ignore();
cout << "Enter the name of the customer:";
getline(cin, CustmerName);
cout << endl << CustmerName;
}
24 = 16 + 8
16 = 2 * 8
8 = 8 * 1
notice that chosing the biggest available cup is the best option, so a greedy algorithm will yield the correct result.
To know how many of each cup you need, you need to review your math from elementary school.
here's a similar problem: «9 friends wants to rent motorbikes for a trip, ¿how many do they need?»
Have you ever seen a program that "calculates the amount of dollars, half-dollars, quarters, nickles, dimes in change"? Different names, same problem.
Integer math. Operators / and %.
PS. "Fewest cups possible." Yeah, right. The sample says that answer is 4 cups.
Take three cups, two Venti and one Grande. Could hold 64oz, but fill them to 57oz.
3<4, or is it? Does one Regular and one Shot really cost less than one Grande (or Venti)?
Well, if the user did enter 29 for CustmerIN and the Venti=24, then your equation computes 29 / 24 and thus the result is that you will effectively do venti = 1.
Note though that your previous code did have Venti, but no venti. Two different names, but look deceptively similar.
Anyway, we have now determined that we have to fill one Venti, but that is not enough.
How should you deliver the rest? How much is the rest?