我必须编写一个程序应用程序,允许员工输入客户订购的汉堡包,薯条和软饮料的数量。
在我的“最终总数”之后,我应该从客户处获得另一部分“输入金额招标:”和“变更:”。我已经写出了代码,我不知道该如何写出招标金额和变更金额?
public class FastFood {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final double pburgers=2.49;
final double pfries=1.89;
final double psodas=0.99;
final double ptax=0.13;
double burgers;
double fries;
double sodas;
double totaltax;
double total;
double tax;
Scanner input = new Scanner(System.in);
System.out.print("Enter the amount of burgers: ");
burgers = input.nextDouble();
System.out.print("Enter the amount of fries: ");
fries = input.nextDouble();
System.out.print("Enter the amount of soft drinks: ");
sodas = input.nextDouble();
totaltax = (burgers*pburgers)+(fries*pfries)+(sodas*psodas);
tax = totaltax*ptax;
total = totaltax + tax;
System.out.format("Total before tax is: $%-5.2f\n", totaltax);
System.out.format("Tax: $%-5.2f\n", tax);
System.out.format("Your final total is: $%-5.2f\n", total);
}
}
答案 0 :(得分:-2)
import java.util.Scanner;
public class FastFood {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final double pburgers=2.49;
final double pfries=1.89;
final double psodas=0.99;
final double ptax=0.13;
double burgers;
double fries;
double sodas;
double totaltax;
double total;
double tax;
double tender;
double change;
Scanner input = new Scanner(System.in);
System.out.print("Enter the amount of burgers: ");
burgers = input.nextDouble();
System.out.print("Enter the amount of fries: ");
fries = input.nextDouble();
System.out.print("Enter the amount of soft drinks: ");
sodas = input.nextDouble();
totaltax = (burgers*pburgers)+(fries*pfries)+(sodas*psodas);
tax = totaltax*ptax;
total = totaltax + tax;
System.out.format("Total before tax is: $%-5.2f\n", totaltax);
System.out.format("Tax: $%-5.2f\n", tax);
System.out.format("Your final total is: $%-5.2f\n", total);
System.out.print("Enter amount tendered: " );
tender = input.nextDouble();
change = tender - total;
System.out.format("Change: $%-5.2f\n", change);
}
}