Question: C++ Programming Write a function named pizza that accepts an input stream and an output stream as parameters. The input stream represents an input file.
C++ Programming

Write a function named pizza that accepts an input stream and an output stream as parameters. The input stream represents an input file. Imagine that a college dorm room contains several boxes of leftover pizza. A complete pizza has 8 slices. The pizza boxes left in the room each contain either an entire pizza, half a pizza (4 slices), or a single slice. Your function's task is to figure out the fewest boxes needed to store all leftover pizza, if all the partial pizzas were consolidated together as much as possible. Your pizza function will read lines from its input where each line of data represents the contents of the pizza boxes in one dorm room. These contents are written as whole, "half" or "slice" in either upper or lower case, separated by at least one space. You should print to the console the number of pizza boxes necessary to store all the slices of pizza out of the total You must use a whole number of boxes. For example, if there are 10 total slices of pizza in a dorm room, 2 pizza boxes are needed: one for the first whole pizza, and one for the final 2 slices. Note that some lines might be blank, meaning that the dorm room contains no pizzas; output for such a case is shown below For example, consider the following input file representing 5 dorm rooms (note that the fourth is blank): slice half slice whole whole half half half whole HALF WhoLE half WHOLE Wh0lE Slice WHOLE slice WHOLE SLICE whole SLICE whole slice WHOLE half half sLICe halF slice For the input above, your function should produce the following output 5/8 pizza boxes used 7/ 10 pizza boxes used 6 10 pizza boxes used 0/0 pizza boxes used 1 / 1 pizza boxes used The format of your output must exactly match that shown above. You may assume that the input stream contains at least 1 line of input, and that no tokens other than whole/half/slice
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
