Question: Please write a Java program that asks the user to enter an integer between 1 and 9 inclusive. Please use a priming read together with
Please write a Java program that asks the user to enter an integer between 1 and 9 inclusive. Please use a priming read together with a while loop to test if the entered integer falls outside this range. If so, continue requesting for a valid integer. Once a valid integer has been entered, please use an outer for loop together with another nested inner for loop to print a pattern similar to the sample runs below. You are to calculate the total number of integers written, and the total sum of all the integers written and print these results at the end. Please use descriptive variable names that conform to Java naming conventions.
run:
Enter an integer between 1 and 9, inclusive:
10
Incorrect. Enter an integer between 1 and 9, inclusive:
0
Incorrect. Enter an integer between 1 and 9, inclusive:
9
1
22
333
4444
55555
666666
7777777
88888888
999999999
The total number of integers written: 45
The total sum of all integers: 285
run:
Enter an integer between 1 and 9, inclusive:
Enter an integer between 1 and 9, inclusive:
3
1
22
333
The total number of integers written: 6
The total sum of all integers: 14
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
