Seperti yang terlihat di atas, Program ini memiliki 3 pilihan rumus.
- Jika memilih 1 kita akan memasuki rumus Massa Jenis
- Jika memilih 2 kita akan memasuki rumus Tekanan
- Jika memilih 3 kita akan memasuki rumus Gaya Berat
Source Code :
import java.util.*;
import java.io.*;
import javax.swing.*;
import java.lang.*;
import java.awt.event.*;
public class eko {
public static void main(String[] args) {
Scanner simpan = new Scanner (System.in);
String loop;
for (loop = "Y"; loop.equals ("Y") || loop.equals ("y");)
{
System.out.println("\t\t ~Rumus Fisika~");
System.out.println("\t\t 1. Massa Jenis");
System.out.println("\t\t 2. Tekanan");
System.out.println("\t\t 3. Gaya Berat");
System.out.print("\t\tPilih Menu (1 s/d 3) : ");
int pilih = simpan.nextInt();
switch(pilih){
case 1:
System.out.println("");
System.out.println("Menghitung Rumus Massa Jenis");
int massa, mas, vol;
Scanner a = new Scanner (System.in);
System.out.println ("");
System.out.println ("1. Mencari Massa Jenis (p)");
System.out.println ("2. Mencari Massa (m)");
System.out.println ("3. Mencari Volume (v)");
System.out.print ("Masukkan pilihan anda = ");
Integer mj = simpan.nextInt();
if (mj==1) {
System.out.println("");
System.out.println("Menghitung Massa Jenis");
System.out.print("Masukkan Massa (kg) = ");
Integer a1 = a.nextInt();
System.out.print("Masukkan Volume (m3) = ");
Integer a2 = a.nextInt();
massa = a1/a2;
System.out.println("Massa Jenisnya adalah = "+massa+" kg/m3");
}
else if (mj==2) {
System.out.println("");
System.out.println("Menghitung Massa");
System.out.print("Masukkan Massa Jenis (kg/m3) = ");
Integer b1 = a.nextInt();
System.out.print("Masukkan Volume (m3) = ");
Integer b2 = a.nextInt();
mas = b1*b2;
System.out.println("Massa adalah = "+mas+" kg");
}
else if (mj==3) {
System.out.println("");
System.out.println("Menghitung Volume");
System.out.print("Masukkan Massa Jenis (kg/m3) = ");
Integer c1 = a.nextInt();
System.out.print("Masukkan Massa (kg) = ");
Integer c2 = a.nextInt();
vol = c2/c1;
System.out.println("Volume adalah = "+vol+" m3");
}
else {
System.out.println("Maaf pilihan anda tidak ada");
}
break;
case 2:
System.out.println("");
System.out.println("Menghitung Rumus Tekanan");
int tek, gay, lua;
Scanner b = new Scanner (System.in);
System.out.println ("");
System.out.println ("1. Mencari Tekanan (p)");
System.out.println ("2. Mencari Gaya (F)");
System.out.println ("3. Mencari Luas Penampang (A)");
System.out.print ("Masukkan pilihan anda = ");
Integer teka = simpan.nextInt();
if (teka==1) {
System.out.println("");
System.out.println("Menghitung Tekanan");
System.out.print("Masukkan Gaya (N) = ");
Integer a1 = b.nextInt();
System.out.print("Masukkan Luas Penampang (m2) = ");
Integer a2 = b.nextInt();
tek = a1/a2;
System.out.println("Tekanan adalah = "+tek+" N/m2");
}
else if (teka==2) {
System.out.println("");
System.out.println("Menghitung Gaya");
System.out.print("Masukkan Tekanan (N/m2) = ");
Integer b1 = b.nextInt();
System.out.print("Masukkan Luas Penampang (m2) = ");
Integer b2 = b.nextInt();
gay = b1*b2;
System.out.println("Tekanan adalah = "+gay+" N/m2");
}
else if (teka==3) {
System.out.println("");
System.out.println("Menghitung Luas Penampang");
System.out.print("Masukkan Gaya (N) = ");
Integer c1 = b.nextInt();
System.out.print("Masukkan Tekanan (N/m2) = ");
Integer c2 = b.nextInt();
lua = c1/c2;
System.out.println("Luas Penampang adalah = "+lua+" m2");
}
else {
System.out.println("Maaf pilihan anda tidak ada");
}
break;
case 3:
System.out.println("");
System.out.println("Menghitung Rumus Gaya Berat");
int gaya, masa, gra;
Scanner c = new Scanner (System.in);
System.out.println ("");
System.out.println ("1. Mencari Gaya Berat (W)");
System.out.println ("2. Mencari Massa Benda (m)");
System.out.println ("3. Mencari Gravitas Bumi (g)");
System.out.print ("Masukkan pilihan anda = ");
Integer gabe = simpan.nextInt();
if (gabe==1) {
System.out.println("");
System.out.println("Menghitung Gaya Berat");
System.out.print("Masukkan Massa Benda (kg) = ");
Integer a1 = c.nextInt();
System.out.print("Masukkan Gravitas Bumi (m/s2) = ");
Integer a2 = c.nextInt();
gaya = a1*a2;
System.out.println("Gaya Berat adalah = "+gaya+" N");
}
else if (gabe==2) {
System.out.println("");
System.out.println("Menghitung Massa Benda");
System.out.print("Masukkan Gaya Berat (N) = ");
Integer b1 = c.nextInt();
System.out.print("Masukkan Gravitas Bumi (m/s2) = ");
Integer b2 = c.nextInt();
masa = b1/b2;
System.out.println("Massa Benda adalah = "+masa+" kg");
}
else if (gabe==3) {
System.out.println("");
System.out.println("Menghitung Gravitas Bumi");
System.out.print("Masukkan Gaya Berat (N) = ");
Integer c1 = c.nextInt();
System.out.print("Masukkan Massa Benda (kg) = ");
Integer c2 = c.nextInt();
gra = c1/c2;
System.out.println("Gravitas Bumi adalah = "+gra+" m/s2");
}
else {
System.out.println("Maaf pilihan anda tidak ada");
}
break;
default:
System.out.println("Sorry, input menu yang anda masukkan tidak sesuai");
break;
}
System.out.print("Ada lagi yg akan dicari? (Y/N) : ");
loop = simpan.next();
}
}
}
Terima Kasih, Semoga Bermanfaat.
EKO PUJI PRASETYO - 2013141800
PARIN JANUAR ABSHAR - 2013142814
RONY ANDRIAN - 2013142192