STUDY
Would you like to react to this message? Create an account in a few clicks or log in to continue.

向下
avatar
Kinsey03
文章數 : 1
積分 : 3
注冊日期 : 2020-09-03

Write a Java program that will calculate and display what it would cost to have a meal delivered by your company. In this invoice, you do not need to display the contents of what the user will order, but only calculate and display the transaction amounts  Empty Write a Java program that will calculate and display what it would cost to have a meal delivered by your company. In this invoice, you do not need to display the contents of what the user will order, but only calculate and display the transaction amounts

周四 9月 03, 2020 7:01 pm
Write a Java program that will calculate and display what it would cost to have a meal delivered by your company. In this invoice, you do not need to display the contents of what the user will order, but only calculate and display the transaction amounts  Phppjv10


Write a Java program that will calculate and display what it would cost to have a meal delivered by your company. In this invoice, you do not need to display the contents of what the user will order, but only calculate and display the transaction amounts that will be paid by the user. The transaction amounts include the input user name, input subtotal amount, the calculated tax amount, the calculated delivery fee amount, the calculated tip amount, and the calculated grand total amount. To begin, the program should display a dialog box prompting the user to enter their name. Next, using a dialog box for input, prompt the user to enter the subtotal amount in currency format. Next, calculate and display the tip amounts for 15%, 20%, and 25% of the subtotal in a dialog box and then prompt the user to enter a percent amount in percent format. The program is ready to begin calculating values: • the tax rate is 6.5% of the subtotal • the delivery fee is 10% of the subtotal • the tip amount (in percent format) of the subtotal • the grand total = subtotal + tax + delivery fee + tip amount All monetary values should be in currency format. Name the class: Invoice
avatar
Josh W.
Contributor
文章數 : 19
積分 : 29
注冊日期 : 2020-05-01

Write a Java program that will calculate and display what it would cost to have a meal delivered by your company. In this invoice, you do not need to display the contents of what the user will order, but only calculate and display the transaction amounts  Empty 回復: Write a Java program that will calculate and display what it would cost to have a meal delivered by your company. In this invoice, you do not need to display the contents of what the user will order, but only calculate and display the transaction amounts

周四 9月 03, 2020 7:31 pm
代碼:
import javax.swing.*;  // importing swing class
class InVoice {  // class InVoice
JFrame f;  // Declaring JFrame to display prompts
InVoice(){  // constructor
    f=new JFrame();  // creating new JFrame
    String name=JOptionPane.showInputDialog(f,"Enter Name:");  //prompt to enter name
    //prompt to enter subtotal amount, the first character denotes currency symbol
    String subTotalAmount=JOptionPane.showInputDialog(f,"Enter the subtotal amount in currency:"+"\nEg $1000");
    char currency= subTotalAmount.charAt(0);
    subTotalAmount = subTotalAmount.substring(1);
   
    //calculating tax
    double tax=6.5/100*Integer.valueOf(subTotalAmount);
    //calculating delivery fee
    double deliveryFee=10.0/100*Integer.valueOf(subTotalAmount);
    //prompt to get percentage
    String percentage=JOptionPane.showInputDialog(f,"15% :"+15.0/100*Integer.valueOf(subTotalAmount)+"\n"+"20% :"+20.0/100*Integer.valueOf(subTotalAmount)+"\n"+"25% :"+25.0/100*Integer.valueOf(subTotalAmount)+"\nEnter the Percentage:");
    percentage=percentage.substring(0,2);
    //calculating tip amount
    double tipAmount=Integer.valueOf(subTotalAmount)*Integer.valueOf(percentage)/100;
    //calculating grand total
    double grandTotal=Integer.valueOf(subTotalAmount)+tax+deliveryFee+tipAmount;
    //displaying transaction amounts
    JOptionPane.showMessageDialog(f,"Subtotal amount:"+subTotalAmount+currency+"\nTax:"+tax+currency+"\n Delivery fee:"+deliveryFee+currency+"\n Tip amount:"+tipAmount+currency+"\n Grand total:"+grandTotal+currency);


public static void main(String[] args) { 
    new InVoice(); 


Write a Java program that will calculate and display what it would cost to have a meal delivered by your company. In this invoice, you do not need to display the contents of what the user will order, but only calculate and display the transaction amounts  Phpeuc10
回頂端
這個論壇的權限:
無法 在這個版面回復文章