ユーザーに購入したパッケージの数を入力するように求めるプログラムを作成する必要があります。プログラムは、割引額と割引後の合計購入額を表示する必要があります。私はこれを中心にプログラムで設計しました..
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 にはシンボルがないと言い続けています。誰かが私の間違いを特定するのを手伝ってくれたら、本当に感謝しています。