Question: using c statements, write a program that should use a while loop to control the flow of the program and continue to prompt the user

using c statements,

write a program that should use a while loop to control the flow of the program and continue to prompt the user with menu choices.

The program should begin by declaring a static int array of length seven. Each element of the array should then be set to 0 (using a for loop). The length of the array should be contained within a named constant , not a literal constant.

the program should then continue by prompting the user with the following menu:

1.Enter last weeks earnings.

2.Predict this weeks earnings.

3.Exit program.

The condition for the while loop should be based on whether or not the user selects option number 3.

If option 1 is selected, the program should do the following:

Prompt the user for seven int values corresponding to the profits earned for each day of last week (in dollars).

The values scanned in from the user should be stored in the static array of length seven discussed above.

The program should then inform the user that the values have been stored successfully. If option 2 is selected, the program should do the following:

Check if the array used in option 1 has been filled with last weeks profit values.

If the array has not yet been filled (meaning the array contains all zeros) , the

program should inform the user that the earnings for last week have not been

entered, so the prediction cannot be made.

If the array has been filled with last weeks earnings (meaning at least one

value is not zero) , continue to the next steps.

Your program should then calculate the mean (average) of last weeks daily profits

(using a for loop), and report this as the estimated average daily profits for this coming

week.

Your program should then reset all of the values in the array used to store the profits

back to 0 (using a for loop).

Therefore, choosing option 1 after this point will be entering profits for a new

week.

If option 3 is selected, your program should do the following:

Print a farewell message to the user.

Then exit the program.

NOT by using an exit statement, but by getting out of the while loop due to the condition evaluating to false, then returning 0 at the end of the program.

After either option 1 or option 2 has been completed, your program should prompt the user with the menu choices again, and continue until option 3 has been selected.

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 Databases Questions!