怎么写,我是刚学不会求帮助
论文问答
1
-
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.println("请输入是否是会员:是(y)/否(其他字符)"); String str = scanner.next(); if ("y".equals(str)) { System.out.println("请输入购物金额:"); BigDecimal bigDecimal = scanner.nextBigDecimal(); if (bigDecimal.compareTo(new BigDecimal("200")) > 1) { bigDecimal = bigDecimal.multiply(new BigDecimal("0.75")); }else { bigDecimal = bigDecimal.multiply(new BigDecimal("0.8")); } System.out.println("实际支付:" + bigDecimal); }else { System.out.println("请输入购物金额:"); BigDecimal bigDecimal = scanner.nextBigDecimal(); if (bigDecimal.compareTo(new BigDecimal("100")) > 1) { bigDecimal = bigDecimal.multiply(new BigDecimal("0.9")); } System.out.println("实际支付:" + bigDecimal); } }
-
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); System.out.println("输入性别:"); String sex=in.next(); System.out.println("输入百米赛成绩:"); float m=in.nextFloat(); if (m<10){ if (sex.equals("男")){ System.out.println("进入男子组"); }else{ System.out.println("进入女子组"); } }else{ System.out.println("很遗憾,未能进入决赛!"); } } }
发表回复