Ask Question
1 December, 03:23

Write code that prints: Ready! firstNumber ... 2 1 Run! Your code should contain a for loop. Print a newline after each number and after each line of text Ex: firstNumber = 3 outputs:

+5
Answers (1)
  1. 1 December, 03:45
    0
    Complete Question:

    Write code that prints: Ready! userNum ... 2 1 Blastoff! Your code should contain a for loop. Print a newline after each number and after each line of text Ex: userNum = 3 outputs: Ready! 3 2 1 Blastoff!

    Answer:

    public class TestClock {

    public static void main (String[] args) {

    int userNum = 3;

    System. out. print ("Ready! "+userNum+" ");

    for (int i=userNum; i>1; i--) {

    userNum--;

    System. out. print (userNum+" ");

    }

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

    }

    }

    Explanation:

    Create and initialize userNum Use System. out. print to print the sequence ("Ready! "+userNum+" ") on same line use for statement with this condition for (int i=userNum; i>1; i--) decremeent userNum by 1 after each loop iteration and print userNum on same line outside the for loop print "Blasoff!"
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write code that prints: Ready! firstNumber ... 2 1 Run! Your code should contain a for loop. Print a newline after each number and after ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers