From d8844630f08c1a512c3f75dbf08b1408ddd0e5fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E6=AD=A3=E6=B3=A2?= <1938448998@qq.com> Date: Thu, 15 Dec 2022 16:40:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?12=E6=9C=8814=E6=97=A5=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...221214 java\345\244\215\344\271\240For.md" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "09 \346\233\271\346\255\243\346\263\242/20221214 java\345\244\215\344\271\240For.md" diff --git "a/09 \346\233\271\346\255\243\346\263\242/20221214 java\345\244\215\344\271\240For.md" "b/09 \346\233\271\346\255\243\346\263\242/20221214 java\345\244\215\344\271\240For.md" new file mode 100644 index 0000000..d4a9500 --- /dev/null +++ "b/09 \346\233\271\346\255\243\346\263\242/20221214 java\345\244\215\344\271\240For.md" @@ -0,0 +1,69 @@ +## 笔记 + +### 字符串的比较 + + 比较基本数据类型:比较的是具体的值 + +​ :比较的是对象(内存)地址值 + + + +## 作业 + +```java +package 十二月14日; + +public class D1 { + //倒列输出乘法口诀 + public static void main(String[] args) { + for (int i=9;i>=1;i--){ + for (int j=1;j<=i;j++){ + System.out.print(j+"×"+i+"="+i*j+" "); + } + System.out.println(); + } + } +} +``` + +```java +package 十二月14日; + +import java.util.Scanner; + +public class D2 { + //购买燃气计算 + public static void main(String[] args) { + //输入需要购买燃气的立方 + Scanner num=new Scanner(System.in); + System.out.println("请输入需要购买燃气的立方"); + int lf=num.nextInt();//立方 + //判断在第几档,定义初始变量 + int csbl=1;//初始变量 + int dw=0;//档位 + if (lf>60){ //第三档 + csbl=60; + dw=3; + } else if (lf>40 && lf<=60) { //第二档 + csbl=40; + dw=2; + } else if (lf<=40 && lf>=1) { //第一档 + csbl=lf; + dw=1; + } + double n=0;//支付金额 + //计算 + if (dw==1){ + n=lf*3.375; + System.out.println("第一档:"+csbl+"立方"+"\n支付金额为:"+n); + } else if (dw==2) { + n=csbl*3.375+(lf-csbl)*4.05; + System.out.println("第一档:"+csbl+"立方"+"\n第二档:"+(lf-csbl)+"立方"+"\n支付金额为:"+n); + } else if (dw==3) { + n=csbl*4.05+(lf-csbl)*5.06; + System.out.println("第二档:"+csbl+"立方"+"\n第三档:"+(lf-csbl)+"立方"+"\n支付金额为:"+n); + } + + } +} +``` -- Gitee From 583709611d96aca39f388cf6c2da36fc7b0bec6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E6=AD=A3=E6=B3=A2?= <1938448998@qq.com> Date: Sun, 18 Dec 2022 13:45:02 +0800 Subject: [PATCH 2/2] =?UTF-8?q?12=E6=9C=8816=E6=97=A5=E4=BD=9C=E4=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20221216 java\346\226\271\346\263\225.md" | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 "09 \346\233\271\346\255\243\346\263\242/20221216 java\346\226\271\346\263\225.md" diff --git "a/09 \346\233\271\346\255\243\346\263\242/20221216 java\346\226\271\346\263\225.md" "b/09 \346\233\271\346\255\243\346\263\242/20221216 java\346\226\271\346\263\225.md" new file mode 100644 index 0000000..eb513b7 --- /dev/null +++ "b/09 \346\233\271\346\255\243\346\263\242/20221216 java\346\226\271\346\263\225.md" @@ -0,0 +1,78 @@ +## 笔记 + +方法的调用格式是 方法名() + +例 getSum(a:100,b:200);参数调用 + +public static void getSum(int a,int b){ + +​ sout(a+b); + +} + +main(函数)主方法 + +定义方法的标准语法: + +public static 返回值类型 方法名(){ + +​ 方法体的具体代码 + +} + +返回值类型:基础类型和引用类型 void(无返回值) + +关于参数:在调用时叫:实际参数,定义时叫:形式参数 + +定义多个相同名的参数时,就调用输出多个。 + +## 作业 + +```java +package 十二月16日; + +import java.util.Scanner; +//定义一函数求两个数中较大的数,并将其返回,这两个数由用户输入。 +public class D1 { + public static void main(String[] args) { + Scanner n1=new Scanner(System.in); + System.out.println("请输入数字1"); + int a= n1.nextInt(); + Scanner n2=new Scanner(System.in); + System.out.println("请输入数字2"); + int b= n2.nextInt(); + int c=getSum(a,b); + System.out.println("最大值是:"+c); + } + public static int getSum(int a,int b ){ + return a>b?a:b; + } +} +``` + + + +```java +package 十二月16日; + +import java.util.Scanner; +//在主函数中从键盘接收X, Y , Z3个数,编写函数计算这3个数的立方和并返回计算结果:S=X3+Y3+Z3 +public class D2 { + public static void main(String[] args) { + Scanner n1=new Scanner(System.in); + System.out.println("请输入X"); + int x= n1.nextInt(); + Scanner n2=new Scanner(System.in); + System.out.println("请输入Y"); + int y= n2.nextInt(); + Scanner n3=new Scanner(System.in); + System.out.println("请输入Z"); + int z= n2.nextInt(); + int s=getSum(x,y,z); + System.out.println("立方和是:"+s); + } + public static int getSum(int x,int y,int z ){ + return x=x*x*x+y*y*y+z*z*z; + } +} +``` \ No newline at end of file -- Gitee