Question: Please write this program in C + + . Today, we will be writing a program to read in the number of pieces of candy

Please write this program in C++. Today, we will be writing a program to read in the number of pieces of candy that a group of 7 children collects on Halloween night and estimating the weight of each child's bag of candy.
Write a program that will do the following:
Create two arrays of datatype double named Pieces and Weight with 7 elements each.
Create a variable of datatype int name numelements and set the value at 7. Use numelements in each of the loops below.
In a loop(you can use either a for loop or a while loop, your choice), prompt the user to enter values for Pieces (i.e. how many pieces of candy did each child collect).
In a separate loop, convert the Pieces of each of the values entered by the user and store the converted value in Weight. In that same loop, print a table with 2 columns that will include the "Number of Pieces" and "Candy Weight"(to 2 decimal places). Use this formula to convert the number of Pieces to Weight (NOTE: you will need to print the labels for each column of the table outside this second loop):
Weight(in pounds)=0.228* No. of Pieces
In a third loop, sum the values of Weight. Once that loop is over, print the total weight of the candy to the screen to 2 decimal places.
Use the following values for Pieces to test your program:
46775563324870

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!