Page 48 - PowerPoint Presentation
P. 48

1.4              1.4.3            MENERANGKAN ALIRAN STRUKTUR

                                                        KAWALAN ULANGAN











                    CONTOH ATURCARA                                              OUTPUT


     public class contoh40 {                                           5,4,3,2,1

         public static void main (String [] args) {
             int n = 5 ;
                 while ( n > 0 ) {
                    System.out.println (n +  “ ,  ” ) ;
                    n = n-1;
             }
         }
     }

     public class Module1 {

         public static void main (String [] args) {
            Scanner scanner = new Scanner (System.in);
            int nom = scanner.nextInt ();


              while (nom > 0 ) {
              nom - = 1;
              System.out.println ( nom + “  ”  ) ;
                 }
             }
     }

     public class contoh42 {                                           Sila masukkan password : Pisang


         public static void main (String [] args) {
              String strPassword = new String ();
              Scanner scanner = new Scanner (System.in);
              final String RekodLaluanRahsia = “Pisang” ;


              while (!strPassword.equal (RekodLaluanRahsia) ) {
                  System.out.print ( “ Sila masukkan password :  ”  ) ;
                  strPassword = scanner.next();
                 System.out.print (  )
                 }
                }
              }


                                                                                                  48
   43   44   45   46   47   48   49   50   51   52   53