任务是:
编写一个程序,为在 XYZ 书店购买任意两本书的会员提供 20% 的折扣。(提示:使用常数变量获得 20% 的折扣。)
我已经打码了,但是不能提示书名,然后显示折扣价。请在下面查看我的编码并根据您的需要进行修改。
import java.util.Scanner;
public class Book_Discount {
public static void main(String args[]) {
public static final double d = 0.8;
Scanner input = new Scanner(System.in);
int purchases;
double discounted_price;
System.out.print("Enter value of purchases: ");
purchases = input.nextInt();
discounted_price = purchases * d; // Here discount calculation takes place
// Displays discounted price
System.out.println("Value of discounted price: " + discounted_price);
}
}