/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication7;
import java.util.Scanner;
/**
*
* @author DELL
*/
public class JavaApplication7 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int harga,total,diskon,jumlah;
System.out.println("Masukkan nama item");
String item=sc.next ();
System.out.println("Masukkan harga");
harga=sc.nextInt();
System.out.println("Masukkan jumlah");
jumlah=sc.nextInt();
total=harga*jumlah;
System.out.println("Total biaya anda adalah "+total);
if (jumlah<3)
{
total = total -((total*15)/100);
System.out.println("Diskon 15%");
}
if (jumlah >= 3){
total = total - ((total*25)/100);
System.out.println("Karena jumlah barang lebih dari 3 maka diskon anda berubah menjadi 25%\nTotal Bayar = Rp."+total);
}
else{
System.out.println("Total Bayar anda = Rp."+total);
}
}
}
Senin, 28 September 2015
Senin, 21 September 2015
Memasukan input dalam netbeans
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tugas_cio;
import javax.swing.JOptionPane;
/**
*
* @author ASUS X550Z
*/
public class Tugas_cio {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String input1;
String input2;
int Harga,Jumlah;
int Biaya;
input1= JOptionPane.showInputDialog("masukkan Harga");
input2= JOptionPane.showInputDialog("masukkan Jumlah");
Harga= Integer.parseInt(input1);
Jumlah= Integer.parseInt(input2);
Biaya= Harga*Jumlah;
JOptionPane.showMessageDialog(null,"Biaya yang dibayar Rp."+Biaya,"Biaya",JOptionPane.PLAIN_MESSAGE);
}
}
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tugas_cio;
import javax.swing.JOptionPane;
/**
*
* @author ASUS X550Z
*/
public class Tugas_cio {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String input1;
String input2;
int Harga,Jumlah;
int Biaya;
input1= JOptionPane.showInputDialog("masukkan Harga");
input2= JOptionPane.showInputDialog("masukkan Jumlah");
Harga= Integer.parseInt(input1);
Jumlah= Integer.parseInt(input2);
Biaya= Harga*Jumlah;
JOptionPane.showMessageDialog(null,"Biaya yang dibayar Rp."+Biaya,"Biaya",JOptionPane.PLAIN_MESSAGE);
}
}
Langganan:
Postingan (Atom)




