- 博客(11)
- 收藏
- 关注
原创 for循环1+....+n
for循环1+…+nimport java.util.Scanner;public class ForDemo { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n=scanner.nextInt(); int sum = 0; for (int i=0;i<=n;i++){
2022-05-19 15:39:58
370
原创 Java while循环1+......+n
Java while循环1+…+nimport java.util.Scanner;public class while01 { public static void main(String[] args) { Scanner scanner=new Scanner(System.in); int n = scanner.nextInt(); int i=0; int sum=0; while (i<=n){
2022-05-19 15:10:30
654
原创 java switch循环
import java.util.Scanner;public class demo_08 {public static void main(String[] args) { Scanner input=new Scanner(System.in); int i=input.nextInt(); //在控制台输入字符switch (i) {case 1: //在控制台输入1则输出 System.out.println("今天出去玩"); break; //不是1则输出default
2021-09-16 14:48:48
68
原创 if elseif scanner语句打印
import java.util.Scanner;public class demo_07 {public static void main(String[] args) { Scanner input =new Scanner(System.in); int i=input.nextInt(); if (i<=10 && i>0) { System.out.println("奖金为"+i*0.1); } else if (i<=20&&am
2021-09-16 14:31:39
84
原创 Java判断学生成绩等级 if elseif语句
public class demo_05 {public static void main(String[] args) { int score=20; if (score>=90&&score<=100) { //成绩为90-100 System.out.println("成绩等级为S"); } else if (score>=80&&score<90) { //成绩为80-90 System.out.println("成绩等级为
2021-09-16 10:37:00
2531
原创 javase判断奇数偶数
public class demo_04 {public static void main(String[] args) { int i=20; if (i%2==0) { System.out.println("这个数是偶数"); } else { System.out.println("这个数是奇数"); }}}
2021-09-16 10:13:39
86
原创 Javase if语句
public class demo_03 {public static void main(String[] args) { int score = 0; if (score==100) { System.out.println("奖励小明一个遥控车"); } else { System.out.println("没有奖励"); }}}
2021-09-16 09:53:30
135
原创 Java面向对象的加减乘除
class number {int a, b;number(int a,int b){this.a=a;this.b=b;}public int sum() { //加法int s1=a+b;return s1;}void display_01() { //方法1调用sum() 方法System.out.println(“和为”+this.sum()); }public int sub() { //减法int s2=a-b;return s2;}void d
2021-09-15 17:12:21
850
原创 Java面向对象编程求三角形面积,周长;梯形面积;圆形周长面积
package pcj.com;class Tangle { int a, b, c; Tangle(int a, int b, int c) { this.a=a; this.b=b; this.c=c; } public double triangleArea(){ float p=(a+b+c)/2f; float s1=(float)Math.sqrt(p*(p-a)*(p-b)*(p
2020-11-08 00:16:44
2258
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人