我是 Java 新手,不明白为什么它不起作用,并在 2 个“ifs”行上说“num 无法解析为可验证的”。感谢您的帮助
package basicJava1;
import java.util.Scanner;
public class DiscountCalculator{
static Scanner reader = new Scanner(System.in);
public static void main(String[] args)
{
double ₪ = 3.5748;
System.out.println("Enter the price");
double price = reader.nextInt();
//
System.out.println("Enter the discount");
double dis = reader.nextInt();
//
if (dis > 99) {
System.out.println("error");
} else {
System.out.println("the price is" + " " + (price-dis*(price/100)));
double priceafter = (price-dis*(price/100));
System.out.println("Would you like to exchange the discounted price from $ to ₪? (1=yes/2=no)");
int num= reader.nextInt();
}
if(num = 1) {
System.out.println("The price is " + ((price-dis*(price/100))*₪) + "₪");
} else {
if(num = 2) {
System.out.println("The price is " + (price-dis*(price/100)) + "$");
} else {
System.out.println("error");
}
}
}
}
慕桂英4014372
12345678_0001
相关分类