Beranda > Tutorial > Tugas II (Source Code Dasar Java)

Tugas II (Source Code Dasar Java)

/**
*
*/
package org.stth.tugasdua;

/**
* @author user
*
*/
import java.io.*;
public class Balok {

/**
* @param args
*/
public static void main(String args[]) throws IOException {
// TODO Auto-generated method stub
System.out.println(“===========Menu===============”);
System.out.println(“1. Meenghitung Volume Balok”);
System.out.println(“2. Luas Permukaan Balik”);
System.out.println(“3. Selisih Volume”);
System.out.println(“4. Selisih Luas Permukaan “);
System.out.println(“5. Keluar”);
BufferedReader kata = new BufferedReader(new InputStreamReader(System.in));
System.out.println(“=============================”);
System.out.print(“Pilih ? [1.2.3.4] :”);
int pilihan = Integer.parseInt(kata.readLine());

switch(pilihan)
{
case 1:
System.out.println(“Panjang”);
double p = Double.parseDouble(kata.readLine());
System.out.println(“Lebar”);
double l = Double.parseDouble(kata.readLine());
System.out.println(“Tinggi”);
double t = Double.parseDouble(kata.readLine());
double v = p*l*t;
System.out.println(“Hasilnya Adalah :”+v);
break;
case 2:
System.out.println(“Panjang”);
double a = Double.parseDouble(kata.readLine());
System.out.println(“Lebar”);
double b = Double.parseDouble(kata.readLine());
double Ls = a*b;
System.out.println(“Hasilnya Adalah :”+Ls);
break;
case 3:
System.out.println(“Panjang”);
double x = Double.parseDouble(kata.readLine());
System.out.println(“Lebar”);
double y = Double.parseDouble(kata.readLine());
System.out.println(“Tinggi”);
double z = Double.parseDouble(kata.readLine());
System.out.println(“Panjang”);
double p1 = Double.parseDouble(kata.readLine());
System.out.println(“Lebar”);
double l1 = Double.parseDouble(kata.readLine());
System.out.println(“Tinggi”);
double t1 = Double.parseDouble(kata.readLine());
double Sl = x*y*z-p1*l1*l1;
System.out.println(“Selisih Vol Adalah :”+Sl);
break;
case 4:
System.out.println(“Panjang”);
double a1 = Double.parseDouble(kata.readLine());
System.out.println(“Lebar”);
double b1= Double.parseDouble(kata.readLine());
System.out.println(“Panjang”);
double a2 = Double.parseDouble(kata.readLine());
System.out.println(“Lebar”);
double b2 = Double.parseDouble(kata.readLine());
double Sl2 = a1*b1-a2*b2;
System.out.println(“Selisih Luas Permukaan Adalah :”+Sl2);
break;
case 5:
System.out.println(“Keluar”);
break;
default:
System.out.println(“Batas input antara 1-4 !”);
break;
}
// akhir case
}
}

Kategori:Tutorial
  1. Belum ada komentar.
  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: