- - Welcome - -

indofairu: Contoh Program Java Input Nilai

Friday, August 10, 2012

Contoh Program Java Input Nilai

Algoritma:
  1. Tentukan variabel Nilai dan i sebagai integer
  2. i ß 1
  3. while i <= 10
  4. cetak ”Please enter Nilai”
  5. input Nilai
  6. IF Nilai >= 60
  7. cetak ”LULUS”
  8. ELSE
  9. cetak ”TIDAK LULUS”
  10. i = i + 1
  11. endwhile
  12. cetak ”Selesai”
  13. Finish

Program Java, sbb:

import java.io.*;
class contoh7
{          public static void main(String [] args)
            {          BufferedReader in = new BufferedReader( new
                        InputStreamReader( System.in) );
                        String oneLine;
                        int Nilai, i = 1;
                        try{
                                    while ( i <= 5)
                                    {
                                    System.out.print(" Please enter Nilai : ");
                                    oneLine = in.readLine();
                                    Nilai =Integer.parseInt( oneLine );
                                    if (Nilai >= 60)
                                                System.out.println("LULUS");
                                    else     
                                                System.out.println("TIDAK LULUS");
                                    i = i + 1;
                                    }         
                                    System.out.println("Selesai");
                        }
                        catch(IOException e){
                        }
            }
}



No comments:

Post a Comment