Question
Write a Java program: reads sequence of 10 integers from the user then prints the complete list of integers that were entered and prints the
Write a Java program: reads sequence of 10 integers from the user then prints the complete list of integers that were entered and prints the average. a) ask the user to "Type integer i: " ( replace "i" with the count of the number that the user is entering). User will enter a number (on the same line as the prompt) that your program will read in as a string. b) Convert the number to an integer using the Integer.parseInt method. c) If the process throws a "NumberFormatException", prints error message (using System.out) reading "Not an integer." on the next line and prompt the user for the number again on the line after that. d) Prompt and read until 10 valid integers have been read. On the next line, print "Your numbers are: ", followed by the list of numbers. Include a space after the colon. Include a comma and a space after each of the first 9 numbers. Don't print a space after the 10th number. On the next line, print "Your average is: " then print the average of the 10 numbers. Use the default formatting for the average. With a new line character at the end of the line (i.e. use println rather than print).
Sample Output:
Type integer 1: 1
Type integer 2: 2
Type integer 3: -1
Type integer 4: Hello
Not an integer.
Type integer 4: 5.5
Not an integer.
Your numbers are: 1, 2, -1
Your average is: (prints average of 10 numbers)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started