Monday, March 26, 2018

CONTOH MEMBUAT PROGRAM RUMUS FISIKA

Codingan membuat program rumus fisika :

import java.util.Scanner;

 public class Rumus_Fisika { 
  public static void main(String args[])
{
    Scanner input= new Scanner(System.in);

double x;
double y;
double z;
double q;
      double hasil;

System.out.println(" MACAM-MACAM RUMUS FISIKA ");
System.out.println(" 1.Momen Inersia(I) ");
System.out.println(" 2.Usaha(W) ");
System.out.println(" 3.Energi Potensial(EP) ");
System.out.println(" 4.Energi Kinetik(EK) ");
System.out.println(" 5.Impuls(i) ");
System.out.println(" 6.Laju_GHS(VGHS) ");
System.out.println(" 7.Ketinggian(H) ");


        for (String i = "Y"; i.equals("Y")||i.equals("y"); ) 
        {
        System.out.println("------------");
        System.out.print("Masukkan Nomor Rumus Yang Anda pilih : ");
        int pilihan = input.nextInt();
System.out.println("_______________");
switch(pilihan) {

case 1:
        System.out.print("Masukkan Nilai konstanta : ");
  x= input.nextDouble();
    System.out.print("Masukkan Nilai massa : ");
    y= input.nextDouble();
    System.out.print("Masukkan Nilai  jari-jari : ");
    z= input.nextDouble();
    
hasil= ( (x*y)*(z*z) );
 System.out.println("I = "+hasil+"  kg.m^2 ");
break;

case 2:
        System.out.print("Masukkan Nilai gaya : ");
  x= input.nextDouble();
    System.out.print("Masukkan Nilai jarak : ");
    y= input.nextDouble();
     
hasil= ( x*y );
 System.out.println("W = "+hasil+"  joule ");
break;

case 3:
        System.out.print("Masukkan Nilai massa : ");
  x= input.nextDouble();
    System.out.print("Masukkan Nilai gravitasi : ");
    y= input.nextDouble();
    System.out.print("Masukkan Nilai  ketinggian : ");
    z= input.nextDouble();
    
hasil= ( x*y*z );
 System.out.println("EP = "+hasil+" joule ");
break;

        case 4:
        System.out.print("Masukkan Nilai massa : ");
  x= input.nextDouble();
    System.out.print("Masukkan Nilai kecepatan : ");
    y= input.nextDouble();
   
hasil= ( 0.5*x*(y*y) );
 System.out.println("EK = "+hasil+"  joule ");
break;

case 5:
        System.out.print("Masukkan Nilai gaya : ");
  x= input.nextDouble();
    System.out.print("Masukkan Nilai waktu ke 1 : ");
    y= input.nextDouble();
System.out.print("Masukkan Nilai waktu ke 2 : ");
    z= input.nextDouble();
       
hasil= ( x*(y-z) );
 System.out.println("i = "+hasil+"  kg.m^2 ");
break;

case 6:
        System.out.print("Masukkan Nilai x0 : ");
  x= input.nextDouble();
    System.out.print("Masukkan Nilai x1 : ");
    y= input.nextDouble();
System.out.print("Masukkan Nilai k : ");
    z= input.nextDouble();
System.out.print("Masukkan Nilai m : ");
    q= input.nextDouble();
       
hasil= ( (x*x-y*y)*(z/q) );
         hasil= Math.sqrt(hasil);
 System.out.println("Laju_GHS = "+hasil+"  m/s^2 ");
break;

case 7:
        System.out.print("Masukkan Nilai gravitasi : ");
  x= input.nextDouble();
    System.out.print("Masukkan Nilai waktu : ");
    y= input.nextDouble();
       
hasil= ( 0.5*x*y );
 System.out.println("Ketinggian = "+hasil+"  m ");
break;


default:
       System.out.println("Maaf Nomor tidak ditemui");
}
System.out.println("Apakah anda mau menghitung rumus lainnya? Y/T");
        i = input.next();

}
}
}

hasil outputnya

     
         
                     
         
     









semoga bermanfaat...
Load disqus comments

0 komentar