1.23实训记录

//高考成绩上大学分类
import java.util.Scanner;

public class Gaokao {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
//提示输入高考成绩
        System.out.println("请输入成绩");
        int score = scanner.nextInt();
        if(score>=650){
            System.out.println("清北");
        }else if (score>550&&score<650){
            System.out.println("一A");
        }else if (score>450&&score<550){
            System.out.println("一B");
        }else if (score>350&&score<450){
            System.out.println("二本");
        }else {
            System.out.println("落榜");
        }
    }
}


//练习1
import java.util.Scanner;

public class ForDame {
    public static void main(String[] args) {
        for (int i = 1; i <= 10; i++)
        {
            if (i % 2 == 0){
                System.out.println(i + " ");}
            }
        }
    }





//练习2
import java.util.Scanner;

public class FourDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入三位数:");
        int num1 = scanner.nextInt();


        int a = num1 / 100;
        int b = num1 / 10 - 10 * a;
        int c = num1 - (a * 100 + b * 10);

        int num2 = c * 100 + b * 10 + a;
        System.out.println("逆序处理后的结果为:" + num2);
    }
}


//练习3  if-else循环
import java.util.Scanner;

public class IfelseDemo2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的身份信息:(军人,学生,还是普通人)");
        String identify = scanner.next();
        //对用户输入的身份信息进行判断
        if("军人".equals(identify)){
            System.out.println("由于您是军人,享受免票");
        }else if("学生".equals(identify)){
            System.out.println("由于您是学生,享受半票");
        }else{
            System.out.println("由于你是普通人,请购买全价票");
        }
    }
}


//练习4 if-else循环
import java.util.Scanner;

public class ifelseDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的成绩:");
        double score = scanner.nextDouble();
        if (score >= 60){
            System.out.println("恭喜你,及格了");
        }else {
            System.out.println("恭喜你,补考一下");
        }
    }
}



//练习5
public class AddDemo01 {
    public static void main(String[] args){
        int a = 3;
        int b = a++;
        System.out.println("b=" +b);
        int c = ++a;
        System.out.println("c=" +c);
    }

}



//练习6 加减乘除取余练习
public class d {
    public static void main(String[] args) {
        //加减乘除取余
        int a = 3;
        int b = 5;

        System.out.println(a + b);//8
        System.out.println(b - a);//2
        System.out.println(a * b);//15
        System.out.println(b / a);//1
        System.out.println(b % a);//2
    }
}


//练习7 下落时间与位移计算
import java.util.Scanner;
public class d1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入下落时间t(整数)");
        int t = scanner.nextInt();
        System.out.println("位移是" +0.5*9.8*t*t);

    }
}


//练习8 For循环
import java.util.Scanner;

public class ForDame {
    public static void main(String[] args) {
        for (int i = 1; i <= 10; i++)
        {
            if (i % 2 == 0){
                System.out.println(i + " ");}
            }
        }
    }

//练习9 双重For循环
public class DoubleForDemo {

        public static void main(String [] args){

            for(int i=1;i<=9;i++){
                for(int j=1;j<=i;j++){

                    System.out.print(i+"*"+j+"="+i*j+" ");
                }
                System.out.println();
            }
        }

    }

//练习10 while循环
public class WhileDemo {
    public static void main(String[] args) {
        int i = 1;
        while(i <= 10){
            System.out.print(i + "");
        }
        i++;
    }
}

//练习11 while循环
import java.util.Scanner;

public class WhileDemo02 {
    public static void main(String[] args) {
        //跑圈 跑完一圈提示用户是否还能跑,如果不能则结束
        Scanner scanner = new Scanner(System.in);
        int i = 1;
        while(true){
            System.out.println("你已经跑了第" + i + "圈,是否继续");
            String str = scanner.next();
            if ("否".equals(str)){
                System.out.println("不行了");
                break;
            }else if ("是".equals(str)){
                i++;
                System.out.println("加油!正在跑第" + i + "圈。");

            }
        }
    }
}

//练习12 Do-while循环
public class DoWhileDemo {
    public static void main(String[] args) {
        int i = 1;

        do {
            System.out.println(i + " ");
            i++;
        }while(i <= 0);
    }
}


//练习13 打印学号,姓名,座右铭
import java.util.Scanner;

public class IdentifyDemo01 {
    public static void main(String[] args){
        //提示用户输入姓名和年龄
        //创建一个键盘扫描器
        Scanner scanner = new Scanner(System.in);
        //提示输入姓名和年龄
        System.out.println("请输入你的学号:");
        String studentnumber = scanner.next();

        System.out.println("请输入你的班级:");
        int  classnumber = scanner.nextInt();

        System.out.println("请输入你的座右铭:");
        String sentence = scanner.next();
        System.out.println("我的学号是" + studentnumber +",班级是" + classnumber + "岁了!" + "座右铭是" + sentence);

    }
}


//练习14 if练习

import java.util.Scanner;

public class IfDemo {
    public static void main(String[] args) {
        //提示用户输入两个数
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入第一个数");
        int a = scanner.nextInt();
        System.out.println("请输入第二个数");
        int b = scanner.nextInt();
        int max = a;
        if (a <= b){
            max = b;
        }
        System.out.println("最大值:" + max);

    }
}

//练习15 switch-case练习

public class month {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入月份:");
        int month = scanner.nextInt();
        switch (month) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println("当月有31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("当月有30天");
                break;
            default:
                System.out.println("当月有28天");
        }
    }
}




//练习16 switch-case练习

import java.util.Scanner;

public class SwitchCaseDemo {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //用户输入名次
        System.out.println("请你输入名次:");
        int num = scanner.nextInt();
        switch (num) {
            case 1:
                System.out.println("欧洲游");
                break;
            case 2:
                System.out.println("亚洲游");
                break;
            case 3:
                System.out.println("国内游");
                break;
            case 4:
                System.out.println("省内游");
                break;
            default:
                System.out.println("加班");
                break;

        }
    }
}



//练习17
import java.util.Scanner;

public class ThreeEyesDemo {
    public static void main(String[] args){
        //提示用户输入一个数
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数:");
        int number = scanner.nextInt();
        //使用三目运算符对用户输入的数进行判断
        String s = number > 0 ? "你输入的是一个正数" :  number == 0 ?"你输入的是0" : "你输入的是一个负数";
        System.out.println(s);


    }
}



//练习18
/*根据用户输入的薪水计算个人所得税并打印出来,其中个税起征点为:5000元,具体规则如下:

        个人所得税起征点每月5000元。个人所得税起征点为5000元/月或60000万元/年,工资范围以及税率:

        1、工资范围在1至5000元之间的,包括5000元,适用个人所得税税率为百分之零;
        2、工资范围在5000至8000元之间的,包括8000元,适用个人所得税税率为百分之三;
        3、工资范围在8000至17000元之间的,包括17000元,适用个人所得税税率为百分之十;
        4、工资范围在17000至30000元之间的,包括30000元,适用个人所得税税率为百分之二十;
        5、工资范围在30000至40000元之间的,包括40000元,适用个人所得税税率为百分之二十五;
        6、工资范围在40000至60000元之间的,包括60000元,适用个人所得税税率为百分之三十;
        7、工资范围在60000至85000元之间的,包括85000元,适用个人所得税税率为百分之三十五;
        8、工资范围在85000元以上的,适用个人所得税税率为百分之四十五*/
import java.util.Scanner;

public class Homework {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的工资:" );
        double num1 = scanner.nextDouble();
        System.out.println("您的个人所得税为:");
        double num2 = 0;
        if (num1 <= 5000 && num1 > 1){
            num2 = 0;
            System.out.println(num2);
        }else if(num1 <= 8000&&num1 > 5000) {
            num2 = (num1 - 5000) * 0.03;
            System.out.println(num2);
        }else if(num1 <= 17000&&num1 > 8000){
            num2 = (num1 - 8000) * 0.1 + 90;
            System.out.println(num2);
        }else if(num1 <= 30000&&num1 > 17000){
            num2 = (num1 + 17000) * 0.2 + 990;
            System.out.println(num2);
        }else if(num1 <= 40000&&num1 > 30000){
            num2 = (num1 + 30000) * 0.25 + 3590;
            System.out.println(num2);
        }else if(num1 <= 60000&&num1 > 40000){
            num2 = (num1 - 40000) * 0.3 + 6090;
            System.out.println(num2);
        }else if(num1 <= 85000&&num1 > 60000){
            num2 = (num1 - 60000) * 0.35 + 12090;
            System.out.println(num2);
        }else if(num1 > 85000){
            num2 = (num1 - 85000) * 0.45 + 20840;
            System.out.println(num2);

        }
    }
}

  • 8
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值