IfExer2.java 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. 女方提出的条件:
  3. 高:180cm以上;富:财富1千万以上;帅:是。
  4. 如果三个条件同时满足:嫁
  5. 如果三个条件有为真的情况,则:嫁吧,比上不足比下有余
  6. 如果三个条件都不满足:不嫁
  7. */
  8. import java.util.Scanner;
  9. class IfExer2{
  10. public static void main(String[] args){
  11. Scanner scan = new Scanner(System.in);
  12. System.out.println("请输入身高:(cm)");
  13. int height = scan.nextInt();
  14. System.out.println("请输入财富值:(千万)");
  15. double wealth = scan.nextDouble();
  16. /*方式一
  17. System.out.println("请输入帅否:(true/false)");
  18. boolean isHandsome = scan.nextBoolean();
  19. if(height >= 180 && wealth >= 1 && isHandsome){
  20. System.out.println("嫁");
  21. }else if(height >= 180 || wealth >= 1 || isHandsome){
  22. System.out.println("嫁吧,比上不足比下有余");
  23. }else{
  24. System.out.println("不嫁");
  25. }
  26. */
  27. //方式二
  28. System.out.println("请输入帅否:(是/否)");
  29. String isHandsome = scan.next();
  30. if(height >= 180 && wealth >= 1 && isHandsome.equals("是")){
  31. System.out.println("嫁");
  32. }else if(height >= 180 || wealth >= 1 || isHandsome.equals("是")){
  33. System.out.println("嫁吧,比上不足比下有余");
  34. }else{
  35. System.out.println("不嫁");
  36. }
  37. }
  38. }