Question
The O-So-Tasty Chocolate Company produces different types of chocolates daily. They need a little summary report that shows how much of each chocolate type they
The O-So-Tasty Chocolate Company produces different types of chocolates daily. They need a little summary report that shows how much of each chocolate type they produce for a given month. This way they can plan next months production schedule.
They record each days production for each chocolate type in a file named Chocolates.
The data indicates the batches of chocolates made each day and is describes as the type of chocolates produced and the number of pieces in each batch. The company makes several different chocolates each day so there will be several different entries for a given day. The input will be two numbers per line where the first number is the chocolate type and the second is the number of pieces made for that batch. There are 25 chocolate types numbered 1 to 30.
For example:
3 30 chocolate number 3 there are 30 pieces
21 45 chocolate number 21 there are 45 pieces
6 28 chocolate number 6 there are 28 pieces
etc..
The company can produce up to 30 different kinds of chocolates. The input file is one month of data.
You are to count the number of chocolates pieces for each kind of chocolate produced and the number of batches for the given month.
The report should have a title and headings. Output for each type of chocolate, the total pieces produced, the total batches produced, the average number of pieces produced in each batch. Label all output and make it a nice readable report, table format.
You must use a 2-D array, pass the array (no global array), and use functions.
Hints:
The chocolates types are 1 to 30. You will need to have one array to keep up with the total pieces (accumulate) for each of the chocolates. Read in a chocolate type and its number of pieces and add to the appropriate location in the array:
infile >> chocolatetype >> pieces;
chocoPieces[ chocolatetype-1] [1] = chocoPieces[ chocolatetype -1 ] [1]+ piecies. Cool isnt it?
You will also have to count the batches and that would be column 2.
Why am I subtracting 1 from the chocolatetype?
You can compute all values for each chocolate type using the data above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started