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();
}
}

Sintak Menghitung Kecepatan Pada JAVA


public class MenghitungKeceptanJarakDanWaktu {
public void test(){
try {
BufferedReader KJ = new BufferedReader(new InputStreamReader(System.in));
double s=0;
double t=0;
System.out.print("Jarak : ");
s=Integer.parseInt(KJ.readLine());
System.out.print("Waktu : ");
t=Integer.parseInt(KJ.readLine());
double v=s/t;
System.out.println("Kecepatan : "+v);
} catch (Exception e) {
// TODO: handle exception
}
}
public static void main(String[] args) {
MenghitungKeceptanJarakDanWaktu M = new MenghitungKeceptanJarakDanWaktu();
M.test();
}
}

Selasa, 06 Desember 2011

Sintak Menghitung Volume Kubus Dan Volume Balok Pada Pascal For Windows



program KubusBalok;
uses
    WinCrt;
var
   p, l, t :integer;
   VolumeKubus : real;
   VolumeBalok : real;
begin
     writeln('Hitung Volume Kubus Dan Balok');
     write('Panjang :');readln(p);
     write('Lebar :');readln(l);
     write('tinggi :');readln(t);
     Volumekubus := p*p*p;
     VolumeBalok := p*l*t;
     write('Volume Balok :',VolumeBalok:2:0);
     writeln(' Meter Kubik');
     write('Volume Kubus :',VolumeKubus:2:0);
     writeln(' Meter Kubik');
end.


Hasil RUN

Postingan Lebih Baru Beranda