Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

C# Help please

Write a do while loop that outputs the following messages:


The rocket will launch in 10 seconds

The rocket will launch in 9 seconds

The rocket will launch in 8 seconds


... all the way to, and including zero


At one second change the message to just say 'second'


When it goes past zero output a message saying 'Rocket Launched!'




And i have done this-


using System;


class MainClass {

 public static void Main (string[] args) {

   

  int counter = 10;

  do{

   Console.WriteLine("The rocket will launch in " + counter + " seconds" );

   counter--;

  }

  while (counter >= 0);

   

   

   

   

   

 }

}

Answers

  • just put this messages out of the loop (if you dont need to do enythig in each itertion other then printing messages)

    .

    .

    .

     while (counter > 1 );

    Debug.Log("second");

    Debug.Log("lunch");


    if you want to keep the messages inside the loop then add if's when the counter is 1 and 0

  • Where would i put it ? Im abit confused.

Sign In or Register to comment.