第二章 JSP开发基础

## 1. Java基本程序设计

### 1.1 变量、常量与数据类型

package phonejudge;
public class ControlFlowExample {

    public static void main(String[] args) {

        int score = 85;

        if (score >= 90) {

            System.out.println("优秀");

        } else if (score >= 75) {

            System.out.println("良好");

        } else {

            System.out.println("继续努力");

        }

        int day = 6;

        switch(day) {

            case 1: System.out.println("星期一"); break;

            case 2: System.out.println("星期二"); break;

            case 3: System.out.println("星期三"); break;
            case 4: System.out.println("星期四"); break;
            case 5: System.out.println("星期五"); break;
            case 6: System.out.println("星期六"); break;
            case 7: System.out.println("星期七"); break;
            default: System.out.println("周末");

        }

        int sum = 0;

        for(int i=1; i<=100; i++) {

            sum += i;

        }

        System.out.println("1-100累加和:" + sum);

        int input = 0;

        java.util.Scanner scanner = new java.util.Scanner(System.in);

        while(input < 1 || input > 10) {

            System.out.print("请输入1-10之间的数字:");

            input = scanner.nextInt();

        }

        System.out.println("您输入的是:" + input);

        int factorial = 1, n = 5;

        int i = 1;

        do {

            factorial *= i;

            i++;

        } while(i <= n);

        System.out.println(n + "! = " + factorial);

    }

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值