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 next 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 each line and display a hash (#) at the end of each line. SAMPLE INPUT/OUTPUT If n = 2 If n = 3 If n = 6 *3332 *223 Invalid 8999999* 55555# +44444 3334 *224 number 14
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 next 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 each line and display a hash (#) at the end of each line. SAMPLE INPUT/OUTPUT If n = 2 If n = 3 If n = 6 *3332 *223 Invalid 8999999* 55555# +44444 3334 *224 number 14
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 14E
Related questions
Question
Java program
![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 next 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
each line and display a hash (#) at the end of each line.
SAMPLE INPUT/OUTPUT
If n = 3
If n = 2
If n = 6
*6666664
55555#
+44442
333#
*224
*333#
*223
Invalid
number
*1#
*1#](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F2a1d0eac-5c9a-4fcc-99fb-25f38ac94553%2F8c7e94b0-09c3-4ba2-af84-9799cd5ac921%2F1gnwbba_processed.jpeg&w=3840&q=75)
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.
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 next 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
each line and display a hash (#) at the end of each line.
SAMPLE INPUT/OUTPUT
If n = 3
If n = 2
If n = 6
*6666664
55555#
+44442
333#
*224
*333#
*223
Invalid
number
*1#
*1#
Expert Solution
![](/static/compass_v2/shared-icons/check-mark.png)
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 2 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
Knowledge Booster
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.Recommended textbooks for you
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
![C++ for Engineers and Scientists](https://www.bartleby.com/isbn_cover_images/9781133187844/9781133187844_smallCoverImage.gif)
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr