Original From : Muhammad Amir

pemrograman pascal

Selasa, 16 November 2010

java tentang diskon

import java.io.*;
class diskon
{
public static void main (String [] args)
{
String x;
int harga=0,jumlah=0,n=0;
int diskon;
try
{
FileInputStream fstream= new FileInputStream ("d:/hargabuncis.txt");
DataInputStream datainput = new DataInputStream(fstream);
while (datainput.available()!=0)
{
x=datainput.readLine();
harga=Integer.parseInt(x);
n=n+1;
jumlah=jumlah+harga;
if (harga<=50000&&harga<=100000) { diskon=harga*0/100; } else if (harga>=100000&&harga<=500000) { diskon=harga*5/100; } else if (harga>500000&&harga<=1000000)
{
diskon=harga*10/100;
}
else
{
diskon=harga*15/100;
}
System.out.println("harga diskon ke "+n+"= "+diskon);
}
datainput.close();
}
catch (Exception e)
{
System.out.println("File Input Error");
}
System.out.println("SUCCES GAN");
}
}

Tidak ada komentar:

Posting Komentar