subject

Allow a user to enter any number of double values up to 20. The user should enter 99999 to quit entering numbers. Display an error message if the user quits without entering any numbers; otherwise, display each entered value and its distance from the average. im using cengage and its only 15% correct but it works?import java. util. Scanner;public class DistanceFromAverage{public static void main(String[] args){double[] input = new double[20];int sentinal = 99999;double value;double total =0;int counter =0;boolean repeat=true;Scanner keyboard = new Scanner(System. in);// read valuesfor (int i = 0; i < input. length && repeat; i++) {System. out. print("Enter a value(99999 to exit):");value = keyboard. nextDouble();// breaks when values is 99999if (value == sentinal) {repeat=false;} else {input[i] = value;total += input[i];counter++;}}double average= total/counter;if (counter == 0)System. out. println("Error! Please enter any values");else {// calculate averageSystem. out. printf("%-10s%-20s\n","value","Dist ance from average");// calculate distancefor (int a = 0; a < counter; a++) {System. out. printf("%-10.2f%-10.2f\n",input[a], average-input[a]);

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 19:30
2. fluorine and chlorine molecules are blamed fora trapping the sun's energyob forming acid rainoc producing smogod destroying ozone molecules
Answers: 2
question
Computers and Technology, 24.06.2019 09:40
Healthy study habits are best described as
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
What is not a type of text format that will automatically be converted by outlook into a hyperlink?
Answers: 1
question
Computers and Technology, 24.06.2019 21:30
Along what line of action can the camera move to follow the movement of actors for screen direction? a. along a 90-degree arcb. along a 120-degree arcc. along a 180-degree arcd. along a 360-degree arc
Answers: 1
You know the right answer?
Allow a user to enter any number of double values up to 20. The user should enter 99999 to quit ente...
Questions
question
Mathematics, 18.03.2021 03:20
question
Mathematics, 18.03.2021 03:20
question
Mathematics, 18.03.2021 03:20
Questions on the website: 13722361