1. Listing
/**
* @(#)agensusu.java
*
*
* @author
* @version 1.00 2012/4/1
*/
import java.util.*;
public class agensusu {
public static void main(String [] args)
{
double hasil,harga,jumbel;
String merk,ukuran,kode;
Scanner input=new Scanner(System.in);
System.out.println("TOKO KELONTONG KERONCONGAN ");
System.out.println("==================================");
System.out.println("A. Susu Dancow");
System.out.println(" 1.Ukuran Kecil");
System.out.println(" 2.Ukuran Sedang");
System.out.println(" 3.Ukuran Besar");
System.out.println("B. Susu Bendera");
System.out.println(" 1.Ukuran Kecil");
System.out.println(" 2.Ukuran Sedang");
System.out.println(" 3.Ukuran Besar");
System.out.println("C. Susu SGM");
System.out.println(" 1.Ukuran Kecil");
System.out.println(" 2.Ukuran Sedang");
System.out.println(" 3.Ukuran Besar");
System.out.print("Input Kode Susu [1/2/3] : " );
kode=input.nextLine();
System.out.print("Input Ukuran Kaleng susu [K/S/B] : " );
ukuran=input.nextLine();
if (kode =="1")
{
if(ukuran=="K")
harga=25000;
else if(ukuran=="S")
harga=20000;
else
harga=15000;
merk="Dancow";
}
else if (kode=="2")
{
merk="Bendera";
if(ukuran=="K")
harga=20000;
else if(ukuran=="S")
harga=17500;
else
harga=13500;
}
else
{
merk="SGM";
if(ukuran=="K")
harga=22000;
else if(ukuran=="S")
harga=18500;
else
harga=17000;
}
System.out.println("Merk Susu :"+ merk);
System.out.println("Ukuran :"+ ukuran);
System.out.println("Harga Satuan Barang :"+harga);
System.out.print("Jumlah yang di beli : " );
jumbel=input.nextDouble();
hasil=jumbel*harga;
System.out.println("Harga yang harus di bayar : "+hasil );
}
}
2. Hasil
Rabu, 04 April 2012
Menghitung Nilai Siswa
1. Listing
/**
* @(#)menghitungnilai.java
*
*
* @author
* @version 1.00 2012/4/4
*/
import java.util.*;
public class menghitungnilai {
public static void main (String [] args)
{
// Membuat variabel
double hadir,tugas,ujian,akhir,a,b,c;
String grade,siswa;
System.out.println("\nPENGHITUNGAN NILAI");
// Membuat objek
Scanner input = new Scanner(System.in);
// membuat inputan
System.out.print("Nama :");
siswa=input.next();
System.out.print("Hadir :");
hadir=input.nextDouble();
System.out.print("Nilai Tugas :");
tugas=input.nextDouble();
System.out.print("Nilai Ujian :");
ujian=input.nextDouble();
// penghitungan
a=hadir*20/100;
b=tugas*30/100;
c=ujian*50/100;
akhir=a+b+c;
// Percabangan
if (akhir>=80)
grade="A";
else if(akhir>=70&&akhir<80)
grade="B";
else if (akhir>=59&&akhir<70)
grade="C";
else
grade="D";
// tampilan
System.out.println("\n------------------------------------------------");
System.out.println("\nNama Siswa:"+siswa);
System.out.println("Dengan Nilai Yang Dipersentasikan");
System.out.println("Hadir :"+a);
System.out.println("Tugas :"+b);
System.out.println("\nSiswa yang Bernama"+siswa);
System.out.println("\n Jadi Siswa yang Bernama "+siswa);
System.out.println("Nilai Akhir Sebesar"+akhir);
System.out.println("Grade:"+grade);
}
}
2. Hasil
/**
* @(#)menghitungnilai.java
*
*
* @author
* @version 1.00 2012/4/4
*/
import java.util.*;
public class menghitungnilai {
public static void main (String [] args)
{
// Membuat variabel
double hadir,tugas,ujian,akhir,a,b,c;
String grade,siswa;
System.out.println("\nPENGHITUNGAN NILAI");
// Membuat objek
Scanner input = new Scanner(System.in);
// membuat inputan
System.out.print("Nama :");
siswa=input.next();
System.out.print("Hadir :");
hadir=input.nextDouble();
System.out.print("Nilai Tugas :");
tugas=input.nextDouble();
System.out.print("Nilai Ujian :");
ujian=input.nextDouble();
// penghitungan
a=hadir*20/100;
b=tugas*30/100;
c=ujian*50/100;
akhir=a+b+c;
// Percabangan
if (akhir>=80)
grade="A";
else if(akhir>=70&&akhir<80)
grade="B";
else if (akhir>=59&&akhir<70)
grade="C";
else
grade="D";
// tampilan
System.out.println("\n------------------------------------------------");
System.out.println("\nNama Siswa:"+siswa);
System.out.println("Dengan Nilai Yang Dipersentasikan");
System.out.println("Hadir :"+a);
System.out.println("Tugas :"+b);
System.out.println("\nSiswa yang Bernama"+siswa);
System.out.println("\n Jadi Siswa yang Bernama "+siswa);
System.out.println("Nilai Akhir Sebesar"+akhir);
System.out.println("Grade:"+grade);
}
}
2. Hasil
Langganan:
Postingan (Atom)