Question: (40 points) Write a complete C program that does the following exactly once: Uses a user validation loop to prompt its user to enter a
(40 points) Write a complete C program that does the following exactly once: Uses a user validation loop to prompt its user to enter a sensor reading that must be an Integer in the range (0,4) into a variable named sensori of type int. . Uses a user validation loop to prompt its user to enter a sensor reading that must be an Integer in the range (0, 41) into a variable named sensor2 of type int. Computes and prints (to the screen) the average of the two sensor values entered Displays exactly one of the following messages (based on the given criteria): - if the average of the two sensor values is equal to 0, print (to the screen): "Are you sure this thing is turned on?" - if the average of the two sensor values is in the range (0, 3.5), print to the screen): All is well" - if the average of the two sensor values is in the range (3.5, 4. print to the screen) "That's a problem!" Sample run(s): run 1 - - ------- -- Enter sensori's value: -10 Enter sensor's value: 8 Enter sensori's value: 0 Enter sensor2's value: -1 Enter sensor2's value: 0 The average of the two sensors was 0.0 Are you sure this thing is turned on? run 1 - run 2 --- Enter sensori's value: 3 Enter sensor2's value: 2 The average of the two sensors was 2.5 All is well run 2 --- run 3 ---------- Enter sensori's value: 4 Enter sensor2's value: 3 The average of the two sensors was 3.5 That's a problem! run 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
