(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
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are u
sed
-classpath Specify where to find user class files
-cp Specify where to find user class files
-sourcepath Specify where to find input source files
-bootclasspath Override location of bootstrap class files
-extdirs Override location of installed extensions
-endorseddirs Override location of endorsed standards path
-d Specify where to place generated class files
-encoding Specify character encoding used by source files
-source Provide source compatibility with specified release
-target Generate class files for specific VM version
-version Version information
-help Print a synopsis of standard options
-X Print a synopsis of nonstandard options
-J Pass directly to the runtime system
C:\Documents and Settings\Sony>java latih6
jumlah lembar copy:34
harga :150
discount :0.0
Total Harga Rp.5100.0
total bayar Rp.5100.0
C:\Documents and Settings\Sony>
Tidak ada komentar:
Posting Komentar