DCT 1093 - Lab 4 - Loops (Lab 4.1)


Example Lab 4.1

[1] Question :

(Conversion from miles to kilometers)
Write a program that displays the following table (note that 1 mile is 1.609 kilometers):


[2] Example Code :

------------------------------------------------------------------------------------------------------------------------
  
    // Step 1 : Use while loop
    int miles = 1;
    while (miles <= ___________)
    {
          // Step 2 : Calculation
          _________________________________

           // Step 3 : Display Result
          System.out.println(________________);
       
           miles++;
    }
  
 -------------------------------------------------------------------------------------------------------------------------


Leave a Reply