diff --git "a/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Circle.java" "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Circle.java" new file mode 100644 index 0000000000000000000000000000000000000000..c59e1d2aa7e588e588dcc000771d76894207ebc0 --- /dev/null +++ "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Circle.java" @@ -0,0 +1,26 @@ +package com.md.lesson8; + +import java.util.Scanner; + +public class Circle { + public static void getCir(double r) { + double cirPer = 3.14*2*r; + + double cirArea = 3.14*r*r; + + System.out.println("圆的周长是:" + cirPer); + System.out.println("圆的面积是:" + cirArea); + + } + + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + + System.out.println("请输入半径:"); + double r = s.nextDouble(); + + getCir(r); + + } + +} diff --git "a/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Cube.java" "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Cube.java" new file mode 100644 index 0000000000000000000000000000000000000000..eec07d45e70f46ed0310846762570d7e49d967fe --- /dev/null +++ "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Cube.java" @@ -0,0 +1,30 @@ +package com.md.lesson8; + +import java.util.Scanner; + +public class Cube { + + public static long cube(long x,long y,long z) { + long rx = x*x*x; + long ry = y*y*y; + long rz = z*z*z; + + long result = rx + ry + rz; + return result; + } + + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + + System.out.println("请输入第一个数:"); + int x = s.nextInt(); + System.out.println("请输入第二个数:"); + int y = s.nextInt(); + System.out.println("请输入第三个数:"); + int z = s.nextInt(); + + long result = cube(x,y,z); + System.out.println("最终结果是" + result); + } + +} diff --git "a/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Factorial.java" "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Factorial.java" new file mode 100644 index 0000000000000000000000000000000000000000..28758f282ea4b0ecf85964af256febf3f0e31b38 --- /dev/null +++ "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Factorial.java" @@ -0,0 +1,31 @@ +package com.md.lesson8; + +import java.util.Scanner; + +public class Factorial { + public static void fac(long a) { + long result3 = 0; + for(int c = 1;c <= a;c++) { + long result1 = 1; + long result2 = 0; + for(int b = 1;b <= c;b++) { + result1 *= b; + result2 += result1; + } + System.out.println(result2); + result3 += result2; + } + System.out.println("最终结果是;" + result3); + } + + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + + System.out.println("请输入一个数:"); + long a = s.nextLong(); + + fac(a); + + } + +} diff --git "a/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Figure.java" "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Figure.java" new file mode 100644 index 0000000000000000000000000000000000000000..5025bb2378a790d9e429219437b42f0839aa21b5 --- /dev/null +++ "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Figure.java" @@ -0,0 +1,51 @@ +package com.md.lesson8; + +import java.util.Scanner; + +public class Figure { + public static double tArea() { + Scanner s = new Scanner(System.in); + System.out.println("请输入底:"); + double bottom = s.nextDouble(); + + System.out.println("请输入高:"); + double height = s.nextDouble(); + + double tArea = (bottom*height)/2; + + System.out.println("三角形面积是:" + tArea); + return tArea; + } + public static double sArea(double l,double w) { + double result = l*w ; + System.out.println("长方形的面积是:" + result); + + return result; + } + public static double rArea(double l) { + double result = l*l; + return result; + } + + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + + double result1 = tArea(); + System.out.println("输入长方形的长:"); + double l = s.nextDouble(); + System.out.println("输入长方形的宽:"); + double w = s.nextDouble(); + double result2 = sArea(l,w); + + System.out.println("输入正方形的边长:"); + double l2 = s.nextDouble(); + + double result3 = rArea(l2); + + double resultFinal = result1 + result2 + result3; + System.out.println("正方形的面积是:" + result3); + System.out.println("面积之和是:" + resultFinal); + + } + +} diff --git "a/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Power.java" "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Power.java" new file mode 100644 index 0000000000000000000000000000000000000000..3253b9585cee32cdc181c22869c077e82453d20b --- /dev/null +++ "b/Java\347\254\254\344\270\203\346\254\241\344\275\234\344\270\232/\351\231\210\346\200\235\351\224\220\347\254\254\345\205\253\346\254\241\344\275\234\344\270\232/Power.java" @@ -0,0 +1,32 @@ +package com.md.lesson8; + +import java.util.Scanner; + +public class Power { + public static void power(int m,int n) { + int result = m; + for(int i = 1;i <= n;i++) { + if(i == 1) { + result = m; + }else { + result = result*m; + } + } + System.out.println("m的n次幂是:" + result); + + } + + public static void main(String[] args) { + Scanner s = new Scanner(System.in); + + System.out.println("请输入底数"); + int m = s.nextInt(); + + System.out.println("请输入指数"); + int n = s.nextInt(); + + power(m,n); + + } + +}