 |
|
รบกวนพี่ๆแก้ไขโค๊ด JAVA โปรแกรมนี้ให้ทีครับ ผมไปไม่ถูกแล้ว(ต้องส่งอาจารย์) |
|
 |
|
|
 |
 |
|
*** รบกวนพี่ๆแก้ให้หน่อยครับ ***
รายละเอียด : ผมต้องการเขียนโปรแกรมขายอะไหล่รถยนต์ โดยเป็น Dialog Box ขึ้นมา เลือกรายการที่จะซื้อ เสร็จแล้วจะมีการคำนวนภาษี ส่วนลด บลาๆๆ สุดท้ายคือให้โชว์รายละเอียดที่ซื้อทั้งหมด(จุดนี้ที่มีปัญหา) น่าจะมีปัญหาตรงแถวๆ "You order" ด้านล่าง น่ะครับ ผมรันไม่ผ่าน! รบกวนพี่ๆแก้ไขให้ทีครับผม พลีสสสส ผมต้องส่งอาจารย์วันพฤหัสซะด้วย T T
Code (Java)
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);
}}
Tag : JavaScript, JAVA, Windows
|
|
 |
 |
 |
 |
Date :
2014-09-22 13:15:16 |
By :
bewofficial |
View :
1659 |
Reply :
3 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
รันไม่ผ่านมี Error หรือได้ Debug ดูไหม๊ครับ ว่าตรงไหนที่มันผิด 
|
 |
 |
 |
 |
Date :
2014-09-23 15:01:53 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (Java)
import java.util.Scanner;
import java.text.DecimalFormat;
import javax.swing.JOptionPane;
public class Ans {
public static void main(String[] args) {
// TODO Auto-generated method stub
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.parseInt(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");name="20%";break;
case 2:price=200;discount=0.20;name=("Headlight");name="20%";break;
case 3:price=300;discount=0.15;name=("Wing Mihor");name="15%";break;
case 4:price=400;discount=0.15;name=("Bumper");name="15%";break;
case 5:price=500;discount=0.10;name=("Fan Belt");name="10%";break;
case 6:price=600;discount=0.10;name=("Brake");name="10%";break;
case 7:price=700;discount=0.05;name=("Spark Plug");name="5%";break;
case 8:price=800;discount=0.05;name=("Gear box");name="5%";break;
case 9:price=900;discount=0.00;name=("Wheel");name="0%";break;
case 10:price=1000;discount=0.00;name=("Indicator");name="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+"\nPrice"+price+"Baht\nPromotion Discount"+name+"\n\nYou order "
+accessory+" piece(s)\nPrice = "+money.format(total)+" Baht\n"+"VAT7% = "+money.format(vat2)+" Baht"+"\n"+"TotalVAT% = "+
money.format(total2)+" Baht\nYou 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);
}
}
|
 |
 |
 |
 |
Date :
2014-10-19 02:25:13 |
By :
SE_MFU |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|