我们已经被指派在我的课堂上用Java制作一个原始的购物车,除了夏威夷的销售税之外,我已经设法完成了所有的工作,而这些税只是拒绝正常工作。如果有人能够指出我做错了什么,我真的很感激,因为我问的每个人都不知道问题是什么。
double IceCreamVanillaPrice = 2.50;
double IceCreamCCPrice = 4.50;
double IceCreamOSPrice = 3.25;
double IceCreamBCPrice = 5.00;
Scanner getInput = new Scanner(System.in);
// Setting up the menu
System.out.println("Hello! Welcome to Neal's Ice Cream Kitchen.");
System.out.println("What would you like?");
System.out.println("-----------------------------------------------
-------");
System.out.println("(1) Vanilla Ice Cream $"+
IceCreamVanillaPrice);
System.out.println("(2) Cookies and Cream Ice Cream $"+
IceCreamCCPrice);
System.out.println("(3) Orange Sherbet Ice Cream $"+
IceCreamOSPrice);
System.out.println("(4) Berry and Cherry Ice Cream $"+
IceCreamBCPrice);
System.out.println("-----------------------------------------------
-------");
System.out.println("Enter the number of the Ice Cream you want to
order.");
// Setting up the ordering system and how much they want as well as
figuring out the total cost
int numIceCream = 0;
numIceCream = getInput.nextInt();
// Vanilla Ice Cream
if (numIceCream == 1) {
System.out.println("How much Vanilla Ice Cream cones do you
want?");
int numVanilla = getInput.nextInt();
double SalesTax1 = numVanilla * IceCreamVanillaPrice + 0.04167 ;
System.out.println("Your total will be $" + SalesTax1); }
// Cookies and Cream Ice Cream
else if (numIceCream == 2) {
System.out.println("How much Cookies and Cream Ice Cream cones
do you want?");
int numCC = getInput.nextInt();
double SalesTax2 = numCC * IceCreamCCPrice + 0.04167 ;
System.out.println("Your total will be $" + SalesTax2); }
// Orange Sherbet Ice Cream
else if (numIceCream == 3) {
System.out.println("How much Orange Sherbert Ice Cream cones do
you want?");
int numOS = getInput.nextInt();
double SalesTax3 = numOS * IceCreamOSPrice + 0.04167 ;
System.out.println("Your total will be $" + SalesTax3); }
// Berry and Cherry Ice Cream
else if (numIceCream == 4) {
System.out.println("How much Berry and Cherry Ice Cream cones
do you want?");
int numBC = getInput.nextInt();
double SalesTax4 = numBC * IceCreamBCPrice + 0.04167 ;
System.out.println("Your total will be $" + SalesTax4); }
else {
System.out.println ("Sorry that is not a Valid Order"); }
System.out.println("Thank you for shopping at Neal's Ice Cream
Kitchen! Have a Nice day!");
`
答案 0 :(得分:5)
看起来你要为每个订单增加4.167美分....你可能想要将每个订单乘以1.04167,如果你正在计算税款。
double SalesTax4 = numBC * IceCreamBCPrice * 1.04167;
答案 1 :(得分:1)
我认为您需要重新审视您的纳税计算声明。 它应该是这样的:salestax = numIC * ICPrice * 1.04167; 如果4.167%是固定的ST费率。