You are to write a program that finds the largest and smallest integer from the
ID: 3623454 • Letter: Y
Question
You are to write a program that finds the largest and smallest integer from the numbers inputted by the user. First you are to prompt the user for the number of integers that the user wants to input, or 'q' to quit. Then in a loop, read in the numbers and find the minimum and maximum integer, outputting both. Note that there should not be any constraint on the number of integers that the user can input - if the user wants to type in a million integers, then let her/him. Test your program for various numbers of integers, say 5, 10, and 15. Also test the values of the integers so that there are positive and negative values, the max is the first value, the max is the last value, the max is in the middle, the max is negative, the max is positive, the min is the first value, the min is the last value, the min is in the middle, the min is negative, the min is positive, ... get the idea???Explanation / Answer
double large= 0; // make a variable that is the worst case scenario of a large number double small =100; // same thing with the small number **assume System.out.print("Enter a number or press "q" to quit"); double num1 = input.nextDouble(); // this is the number that user enters String quitKey = input.next(); while(!quitKey.equals("q")) { System.out.print("Enter a number or press "q" to quit"); double num1 = input.nextDouble(); if (num1 > large) { large = num1; } else if (num1Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.