Home > Java > javaTutorial > Java fitness planning program implementation

Java fitness planning program implementation

王林
Release: 2023-04-23 08:25:06
forward
1207 people have browsed it

Weight loss plan

Title:

Enter the number of weeks to display today’s weight loss plan

Analysis:

  • Keyboard entry A week number is received in a variable;

  • uses the switch statement for judgment;

  • outputs the corresponding statement.

Practice:

The code is as follows (example):

public class Demo3 {
    public static void main(String[] args) {
    //不爱生姜不吃醋
        // 键盘录入一个星期数,用一个变量接收;
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入星期数:");
        int week=sc.nextInt();

        // 使用switch语句进行判断;
        switch(week){
            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("输入的星期数有误!");
                break;
        }
    }
}
Copy after login

The above is the detailed content of Java fitness planning program implementation. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Install JAVA
From 1970-01-01 08:00:00
0
0
0
Unable to install java
From 1970-01-01 08:00:00
0
0
0
Can java be used as the backend of the web?
From 1970-01-01 08:00:00
0
0
0
Is this in Java language?
From 1970-01-01 08:00:00
0
0
0
Help: JAVA encrypted data PHP decryption
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template