2.3k views
4 votes
Write code that prints: Ready! numVal ... 2 1 Go! Your code should contain a for loop. Print a newline after each number and after each line of text Ex: numVal = 3 outputs: Ready!

3
2
1
Go!
public class ForLoops {
public static void main (String [] args) {
int countNum;
int i;
countNum = 3;
/* Your solution goes here */
}
}

1 Answer

1 vote

Answer:

public class ForLoops {

public static void main (String [] args) {

int countNum;

int i;

countNum = 3;

System.out.println("Ready!");

for(i = countNum;i>0;i--) {

System.out.println(i);

}

System.out.println("Go!");

}

}

Output:

Write code that prints: Ready! numVal ... 2 1 Go! Your code should contain a for loop-example-1
User Dsnettleton
by
5.1k points