Write a dowhile loop that prompts the user to enter a number

Write a do-while loop that prompts the user to enter a number between 1 and 10 until successful input is collected. Use nested for loops to create a difference table. Each entry in the table should be |column - row|. You can use Math.abs(). Include row and column headings. Eg: n = 4 (4 times 4 table) Collect two numbers from the user so that the table can be m times n (both 1

Solution

Please find the required program along with its output. Please see the comments against each line to understand the step.

1)

---------------------------

OUTPUT:

Enter a number between 1 - 10:
23
Number not in given range. Try again
as
Invalid format. Enter integer number:
Number not in given range. Try again
21
Number not in given range. Try again
6
Successful input. Number : 6

2)

----------------------

Enter order of the matrix:
4
OUTPUT:
1 2 3 4
1 0 1 2 3
2 1 0 1 2
3 2 1 0 1
4 3 2 1 0

 Write a do-while loop that prompts the user to enter a number between 1 and 10 until successful input is collected. Use nested for loops to create a difference

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site