Write a C++ program that reads a number of pizza slices and expresses it as the smallest possible combination of whole pizzas (8 slices), half-pizzas (4 slices), quarter-pizzas (2 slices), and single slices. The smallest possible combination means using as many larger units as possible so that the total number of items (pizzas, halves, quarters, singles) is minimized. For example:
Enter the number of slices: 83
The input corresponds to
Whole pizzas (8 slices): 10
Half-pizzas (4 slices): 0
Quarter-pizzas (2 slices): 1
Single slices: 1
The input is assumed to be an integer with a size range from 1 to 1000.
The outputs of your program should be exactly the same as those in the input-output samples.
Every character in the output (spaces, newlines, punctuation, and letters) should be identical to the provided samples.
Before submitting assignments, ensure that your program successfully handles the input-output examples provided above.
Output formatting:
Check the code template first, so you’ll know the expected input and output before you start coding.
It is recommended to modify the code template to complete the assignment.
The following line is from the code template.
cout << "Whole pizzas (8 slices): " << variable1 << endl;
The following is INCORRECT, because it removes a space from the string enclosed by double quotes.
cout << "Whole pizzas (8 slices):" << variable1 << endl;
The following is INCORRECT, because it outputs extra line breaks caused by system("pause").
cout << "Whole pizzas (8 slices): " << variable1 << endl; system("pause");
The following is INCORRECT, because it outputs extra endl.
cout << "Whole pizzas (8 slices): " << variable1 << endl; cout << endl;
Suggestions:
Rename variable1 through variable4 with meaningful names.
Remove comments.
Typically, if your variable names are descriptive, there's no need to include comments.
Ensure that you use the integer type (not floating-point) throughout your code for this assignment.