题解 | #网购#
网购
https://www.nowcoder.com/practice/5d7dfd405e5f4e4fbfdff6862c46b751
//字符串比较是否相等应使用equals方法 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String[] str=in.nextLine().split(" "); double money=Double.parseDouble(str[0]); /* int month=Integer.parseInt(str[1]); int day=Integer.parseInt(str[2]); int bargar=Integer.parseInt(str[3]);*/ if(str[1].equals("11")&&str[2].equals("11")||str[1].equals("12")&&str[2].equals("12")){ double discount=str[1].equals("11")?0.70:0.80; money*=discount; if(str[3].equals("1")){ money-=50; } } System.out.printf("%.2f",Math.max(money,0)); } }