In a file called Stars.java, write a program that: Asks the user to enter a positive integer N > 0. It is OK if your program crashes when the user does not enter a valid integer. If N <= 0, the program terminates. If N > 0, the program prints out: A line with one character '*'. A line with two characters '*'. A line with three characters '*'. And so on, up to and including a line with N characters '*'. For example: if the user enters 5, your program output should look EXACTLY like this:Enter a positive integer N > 0: 5 * ** *** **** ***** Exiting... As another example: if the user enters 0, your program output should look EXACTLY like this:Enter a positive integer N > 0: 0 Exiting... As another example: if the user enters 1, your program output should look EXACTLY like this:Enter a positive integer N > 0: 1 * Exiting...

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter7: Characters, Strings, And The Stringbuilder
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question
100%

In a file called Stars.java, write a program that:

  • Asks the user to enter a positive integer N > 0. It is OK if your program crashes when the user does not enter a valid integer.
  • If N <= 0, the program terminates.
  • If N > 0, the program prints out:
    • A line with one character '*'.
    • A line with two characters '*'.
    • A line with three characters '*'.
    • And so on, up to and including a line with N characters '*'.

For example: if the user enters 5, your program output should look EXACTLY like this:Enter a positive integer N > 0: 5 * ** *** **** ***** Exiting... As another example: if the user enters 0, your program output should look EXACTLY like this:Enter a positive integer N > 0: 0 Exiting... As another example: if the user enters 1, your program output should look EXACTLY like this:Enter a positive integer N > 0: 1 * Exiting...

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Constants and Variables
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning