Need Help on Basic Program

closed account (16MjE3v7)
I have finished other elements of the program, but I am not sure where to go on this one. Yes I am a beginner. I don't know how to perform these divisions with leftovers and such and how to make it all work. Any help would be appreciated.

Determine and report the number of large, medium, and small pizzas you need to order
For every 7 guests, order one large pizza
For every 3 guests left over, order one medium pizza
For every 1 guest left over, order one small pizza


If you are trying to find the remainder, you need to use the modulus operator (%). For example, ( 7 % 2 ) would return the remainder of 7/2, which is 1.
closed account (16MjE3v7)
I know how to do that. I guess I just don't know how to do more than the first part ha
This maybe?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int guests = 20;
int largePizza;
int mediumPizza;
int smallPizza;

//large pizza
largePizza = guests / 7;
guests = guests % 7;

//medium pizza
mediumPizza = guests / 3;
guests = guests %3;

//small pizza
smallPizza = guests / 1;

cout << "For " << guests << " guests order: " << endl;
cout << largePizza << " Large pizzas. " << endl;
cout << mediumPizza << " Medium Pizzas. " << endl;
cout << smallPizza << " Small Pizzas. " << endl;


Topic archived. No new replies allowed.