Question: Exercise 2: Using the While Loop a program that uses a while loop to accomplish the same calculations as in Exercise 1. The program should

Exercise 2: Using the "While Loop"

a program that uses a while loop to accomplish the same calculations as in Exercise 1. The program should capture your input values and assign the values to a variable. Use the same target value as in Exercise 1.

  • Hint:
  • Define a variable called continue_loop and assign it the value of "Y".
  • Define a variable called "target" and assign it the value of 35500.

Your program should:

  • Use a while loop.
  • Prompt a user to input a site's expenditure and upon hitting the return key:
  • Ask if they want to add another expenditure with the options of "Y" or "N" (as long as the "continue_loop" variable is equal to "Y"). (Hint:The loop should end if the user input is anything but "Y".)
  • Validate that the data entered is not below zero (review Chapter 4, Program 4-16 to see an example of input validation). If the value is below 0, present a message that says "Values must be greater than 0."
  • Calculate the average IT expenditure.
  • Display the average IT expenditure.
  • Compare that value to the target.
  • Display one of the following messages:
  • "This site is meeting the organization's target goals!" if the average is equal to or below the target.
  • "This site is NOT meeting the organization's target goals." if it is above the average.

Save and run the program and take a screenshot of your code and the results of running the program after all inputs have been made.

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!