Example Lab 3.3
[1] Question :
One million is 106 and 1 billion is 109. Write a program that reads a power of 10 (6, 9, 12, etc.) and displays how big the number is (Million, Billion, etc.).
Display an appropriate message for the input value that has no corresponding word.
[2] Example Code :
------------------------------------------------------------------------------------------------------------------------
     // Step 1 : Prompt the input
     Scanner input = new Scanner(System.in);
   
    // Step 2 : Enter an power of 10
     System.out.print("_____________________");
     int number = input.nextInt();
   
    // Step 3 : Selection statement + Display Result
    switch (power)
    {
          case 6 : 
                    System.out.print("Milion" );
                    break; 
          case _ : 
                    System.out.print("______________________" );
                    break;
     } 
 -------------------------------------------------------------------------------------------------------------------------
DCT 1093 - Lab 3 - Selections (Lab 3.3)
Thursday, 10 January 2013
You can leave a response
zT-FKMPT
Jabatan Sains Komputer . Fakulti Komputer, Media, & Pengurusan Teknologi . TATIUC
 
