From 585761972438a531d62ae14bb9ccf08f84d9be34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E5=AD=90=E8=B1=AA?= <2936219414@qq.com> Date: Thu, 1 Dec 2022 18:57:51 +0800 Subject: [PATCH] zy3 --- .../zy3.md" | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 "54 \345\217\266\345\255\220\350\261\252/zy3.md" diff --git "a/54 \345\217\266\345\255\220\350\261\252/zy3.md" "b/54 \345\217\266\345\255\220\350\261\252/zy3.md" new file mode 100644 index 0000000..d67c425 --- /dev/null +++ "b/54 \345\217\266\345\255\220\350\261\252/zy3.md" @@ -0,0 +1,38 @@ +利用三元运算符求任意三个数中最大者 【三元】 + +public class zy3 { + public static void main(String[] args) { + int a =5; + int b =6; + int c =7; + int d= a > b ? a:b; + int e = c > d ? c : d; + System.out.println("输出的最大的数是"+e); + + } +} + + + 现有父亲身高177CM,母亲身高165CM。求子女身高分别预计为多少?【使用变量的定义和算术运算符完成本题】 + +public class zy4 { + public static void main(String[] args) { + int a =177; + int b =165; + double c = (a+b)*1.08/2; + double d = (a*0.923+b)/2; + System.out.println("儿子身高为:"+c+"cm"+ "女儿身高为:"+d+"cm"); + + } +} + + + 那么红茶和绿茶现在的钱一样多,请问对么?【使用赋值运算符和算术运算符计算各自的钱,使用比较运算符对比大小】 + +public class zy5 { + public static void main(String[] args) { + int a =21*2+3; + int b =24*2; + System.out.println(a == b); + } +} \ No newline at end of file -- Gitee