Write a java program that uses nested for-loops to display a sequence of numbers. The program should ask the user to enter an integer n. The number n should be in the range 3 to 1000. If the number is not in the range, then display an invalid message and exit the program. Otherwise, on the first line, the program should display the number n repeated n times. Then on the neCt line it should display the number n - 1 repeated n-1 times, and on the next line it should display the number n -2 repeatedn -2 times, and so on for the next lines and stop when the number reaches zero. Also, display a star (*) before each line and display a hash (#) at the end of each line. See sample input/output on the right side SAMPLE INPUT/OUTPUT If n = 3 If n = 2 If n = 6 *3332 *224 Invalid *555554 *4444# *333# *224 number *1# *1#

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section5.5: A Closer Look: Loop Programming Techniques
Problem 13E
icon
Related questions
Question
100%
Java
Write a java program that uses nested for-loops to display a sequence
of numbers. The program should ask the user to enter an integer n.
SAMPLE INPUT/OUTPUT
If n = 6
If n = 2
Ifn = 3
The number n should be in the range 3 to 1000. If the number is not in
the range, then display an invalid message and exit the program.
Otherwise, on the first line, the program should display the number n
repeated n times. Then on the net line it should display the number
n - 1 repeated n – 1 times, and on the next line it should display the
number n – 2 repeated n – 2 times, and so on for the next lines and
stop when the number reaches zero. Also, display a star (*) before
*3332
*223
*1#
*666666
*55555#
*4444
*333
Invalid
number
*224
*1#
each line and display a hash (#) at the end of each line.
See sample input/output on the right side
Transcribed Image Text:Write a java program that uses nested for-loops to display a sequence of numbers. The program should ask the user to enter an integer n. SAMPLE INPUT/OUTPUT If n = 6 If n = 2 Ifn = 3 The number n should be in the range 3 to 1000. If the number is not in the range, then display an invalid message and exit the program. Otherwise, on the first line, the program should display the number n repeated n times. Then on the net line it should display the number n - 1 repeated n – 1 times, and on the next line it should display the number n – 2 repeated n – 2 times, and so on for the next lines and stop when the number reaches zero. Also, display a star (*) before *3332 *223 *1# *666666 *55555# *4444 *333 Invalid number *224 *1# each line and display a hash (#) at the end of each line. See sample input/output on the right side
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr