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; } } }
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!