import java.text.DecimalFormat;
import javax.swing.JOptionPane;
import java.util.Scanner;
public class AccessoryShop{
public static void main(String[] args){
int choose,accessory;
int repeat;
String name=",promo";
double net=0;
double vat2=0;
double discount=0;
double price=0;
double total=0;
double total2=0;
double totaldis=0;
String input;
DecimalFormat money = new DecimalFormat("#,##0.00");
Scanner keyboard = new Scanner(System.in);
do{
input = JOptionPane.showInputDialog("Welcome To AccessoryShop!"+"\n"+"Please select the accessory you want to buy!"+"\n"+"OUR Accessory Released"+
"\n"+"1.Battery"+ "\n" +"2.Headlight"+ "\n" +"3.Wing mihor"+"\n"+"4.Bumper"+"\n"+"5.Fan Belt"+"\n"+"6.Brake"+"\n"+"7.Spark Plug"
+"\n"+"8.Gear box"+"\n"+"9.Wheel"+"\n"+"10.Indicator");
choose=Integer.parselnt(input);
if(choose>10){
JOptionPane.showMessageDialog(null, "You got the wrong choice. We will Exit the program.");
System.exit(0);
}
input=JOptionPane.showinputDialog("Please input number of accessory you want to buy.");
accessory=Integer.parseInt(input);
switch(choose){
case 1:price=100;discount=0.20;name=("Battery");promo="20%";break;
case 2:price=200;discount=0.20;name=("Headlight");promo="20%";break;
case 3:price=300;discount=0.15;name=("Wing Mihor");promo="15%";break;
case 4:price=400;discount=0.15;name=("Bumper");promo="15%";break;
case 5:price=500;discount=0.10;name=("Fan Belt");promo="10%";break;
case 6:price=600;discount=0.10;name=("Brake");promo="10%";break;
case 7:price=700;discount=0.05;name=("Spark Plug");promo="5%";break;
case 8:price=800;discount=0.05;name=("Gear box");promo="5%";break;
case 9:price=900;discount=0.00;name=("Wheel");promo="0%";break;
case 10:price=1000;discount=0.00;name=("Indicator");promo="0%";break;
}
total=(price*accessory);
vat2=(price*accessory)*0.07;
total2=(price*accessory)+vat2;
totaldis=(price*accessory)*discount;
net=((price*accessory)+vat2)-totaldis;
JOptionPane.showMessageDialog(null, "You selected accessory:"+name+"\n"+"Price"+price+"Baht"+"\n"+"Promotion Discount"+promo+"\n\n\n"+
"You order"+accessory+"piece(s)"+"\n"+"Price ="+money.format(total)+"Baht"+"\n"+VAT7%=+money.format(vat2)+"Baht"+"\n"+"TotalVAT%="+
money.format(total2)+"Baht"+"\n"+"You get discount="+money.format(totaldis)+"Baht"+"\n"Net="+money.format(net)+"Baht");
repeat=JOptionPane.showConfirmDialog(null, "Continue?","Test",JOptionPane.YES_NO_OPTION);
}while(repeat==JOptionPane.YES_OPTION);
System.exit(0);
}}