Jumat, 01 Juli 2011

FUNGSI DI JAVA


import java.io.*;
class latfungsi{
    public static void main(String Arg[])throws IOException{
        String str;
        double xtot=0;
        BufferedReader Get=new BufferedReader(new InputStreamReader(System.in));
        latfungsi fungsi=new latfungsi();
        System.out.print("Input total Harga:");str=Get.readLine();
        xtot=Double.parseDouble(str);
        System.out.print("discount:"+fungsi.hitung(xtot));
    }
    double hitung(double total){
        double discount;
        if(total>=2000000)discount=0.1*total;
        else if(total>=1000000)discount=0.05*total;
        else discount=0;return(discount);
     }
}

hasilnya:

Tidak ada komentar:

Posting Komentar