I need assistance with the following:
Write the Java code which uses iteration to produce the following output::
1
1 2
1 2 3
1 2 3 4
////////////////////////////////////////////////////////////////
My Source code: (Not correct) Please review, I must include a loop to produce output as follows:
1
1 2
1 2 3
1 2 3 4
My code is posted below, I have a working copy but is not 100% accurate. This is due in a matter of hours and I really need assistance to ensure that I get this one right.
///////////////////////////////////////////////////////////
import java.util.*;
public class OneTwoThreeFourIteration
{
public static void main(String[] args)
{
int count, number;
System.out.println("Enter number 4");
Scanner keyboard = new Scanner(System.in);
number = keyboard.nextInt( );
count = 1;
do
{
System.out.print(count + ", ");
count++;
}while (count <= number);
System.out.println( );
System.out.println("Here is the requested results.");
System.out.println("1");
System.out.println("1 2");
System.out.println("1 2 3");
System.out.println("1 2 3 4");
System.out.println("The End!");
}
}