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, 22.06.2019 18:00
Write a method named addall that could be placed inside the hashintset class. this method accepts another hashintset as a parameter and adds all elements from that set into the current set, if they are not already present. for example, if a set s1 contains [1, 2, 3] and another set s2 contains [1, 7, 3, 9], the call of s1.addall(s2); would change s1 to store [1, 2, 3, 7, 9] in some order. you are allowed to call methods on your set and/or the other set. do not modify the set passed in. this method should run in o(n) time where n is the number of elements in the parameter set passed in.
Answers: 2
question
Computers and Technology, 24.06.2019 18:10
Most information security incidents will occur because of select one: a. users who do not follow secure computing practices and procedures b. increases in hacker skills and capabilities c. poorly designed network protection software d. increasing sophistication of computer viruses and worms
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
How does the use of e-mail benefit business communications? it can be sent at any time. it is faster than regular mail. it improves writing skills. it is less expensive than using a courier. it reduces the need for proofreading.
Answers: 1
question
Computers and Technology, 24.06.2019 23:30
Game design colleges anyone know the requirements? ?
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, 17.04.2020 20:04
question
Social Studies, 17.04.2020 20:05
Questions on the website: 13722363