Rabu, 07 Desember 2011

Sintak Menghitung Kelipatan 5 Pada JAVA

public class Kelipatan5 {
public void kelipatan(){
   try{
       BufferedReader Test = new BufferedReader(new InputStreamReader(System.in));
       int d,i,test,test1;
       int jmlh=0;
       int a = 5;
       int bukan = 0;
       System.out.print("Nilai Awal = ");
       i=Integer.parseInt(Test.readLine());
        System.out.print("Nilai Akhir = ");    
        d=Integer.parseInt(Test.readLine());
               for (i=+i;i<=d;i++){
                test=0;
                        test1=1;
                    jmlh=i%a;
                                   if (jmlh==0){
                                       test=1;
                                   }
                               if (test1==test){
                                       System.out.print(i+"\t");
                               }
                               else {
                                bukan = bukan +i;
                               }
                               
               }
               System.out.println();
               System.out.println("Total Yang Bukan Bilangan Kelipatan 5 : "+bukan);
  }catch(IOException e){
      System.out.println("Error : "+ e.getMessage());
  }
 }
public static void main(String[] args) {
Kelipatan5 M = new Kelipatan5();
M.kelipatan();
}
}

Posting Lebih Baru Posting Lama Beranda

0 komentar:

Posting Komentar