我必须编写一个程序,要求用户输入购买的包裹数量。然后程序应显示折扣金额和折扣后的购买总额。我是围绕这个程序设计的..
import java.util.Scanner;
public class softwareSales
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
double Package = 99, discount, priceBfDiscount, discountPrice, totalPrice;
int quantity;
System.out.println("This is a software sales program");
System.out.println("Enter number of packages");
quantity = input.nextInt();
System.out.println("Enter price of package");
Package = input.nextDouble();
System.out.println("Enter gross price");
priceBfDiscount = input.nextDouble();
priceBfDisc = Package * quantity;
discountPrice = priceBfDisc * discount;
totalPrice = priceBfDisc - discountPrice;
System.out.println("The price before discount is $" + priceBfDisc);
System.out.println("The discount price is $" + discountPrice);
System.out.println("The total price is $" + totalPrice);
if (quantity >= 10 && quantity <= 19)
{
System.out.println("The discount is .20");
}
else if (quantity >=20 && quantity <=49)
{
System.out.println("The discount is .30");
}
else if (quantity >=50 && quantity <=99)
{
System.out.println("The discount is .40");
}
else if (quantity >=100)
{
System.out.println("The discount is .50");
}
}
我不知道错误是什么。它一直说 priceBfDisc 没有符号。因此,如果有人可以帮助我找出我的错误,我将不胜感激。