answersLogoWhite

0


Best Answer

// Set up a Scanner class to read from standard input
final Scanner in = new Scanner(System.in);

// Prompt for input and read the next integer
System.out.print("Please enter a positive integer: ");
int n = in.nextInt();

// Since we want to print out n lines, iterate n times
for (; n > 0; --n) {

// On each iteration, print out the numbers [1,n]
for (int i = 1; i <= n; ++i) {
System.out.print(i + " ");

}
System.out.println();

}

// Remember to close open resources when we're done.
in.close();

User Avatar

Wiki User

14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: In Java you want to write a program that will prompt the user for a nonnegative value n the program will then do as follows in the discussion help please?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Algorithms to the given c plus plus programs?

The question is impossible to answer. You cannot determine an algorithm from a given program if the program is not actually given in the question. Please place the program in the discussion section.


What is the mentoring question of Vigorouschemist?

It's nice to take part in the mentoring program. Please do not edit, change or trash this question and the discussion. This content is used for mentoring purposes.


Can anyone translate some Chinese for you SEE Discussion?

Please see the Discussion area.


Did I do any damage to my car please see discussion?

More details please. What happened? Answer: I wrote all the details under the discussion tab.


What is the LCM of 1261?

Please refer to Discussion...


What is the homophone for nail?

The homophone for &quot;nail&quot; is &quot;kneel.&quot;


What are the words to can you have your number?

Please see discussion area.


Why is it so complicated?

Please refer the discussion area


Why not have a world currency like the dollar DISCUSS?

I want to turn this into a discussion please so please post there if you can


What are the lyrics to Triple H's theme?

Please see the discussion area.


How do you sew an embroidered collar?

Please use the Discussion area to be more specific.


Where can you find a non-custodial parent for free?

Please see discussion page.