(ketik di notepa>save as di folder sony)
import java.io.*;
public class latih6{
public static void main(String Arg[])throws IOException{
String str; int jumlah,harga=0;double total,disc=0;
BufferedReader Get=new BufferedReader(new InputStreamReader(System.in));
System.out.print("jumlah lembar copy:");str=Get.readLine();
jumlah=Integer.parseInt(str);
if (jumlah>500) harga=90;
else if(jumlah>250) harga=105;
else if(jumlah>100) harga=125;
else harga=150;
total=harga*jumlah;
System.out.println("harga :"+harga);
if (jumlah>600)disc=0.1*total;
System.out.println("discount :"+disc+"\n Total Harga Rp."+total);
System.out.println("total bayar Rp."+(total-disc));
}
}
ketik run>cmd
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Sony>set path=C:\Program Files\Java\jdk1.5.0_11\bin
C:\Documents and Settings\Sony>javac latih6.javac
javac: invalid flag: latih6.javac
Usage: javac
Tidak ada komentar:
Posting Komentar