How to realize the weight loss Planning Program by java
This article mainly shows you "java how to achieve weight loss planning program", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "java how to achieve weight loss planning program" this article.
Weight loss plan
Title:
Enter the number of weeks to display today's weight loss plan
Analysis:
Enter the number of weeks on the keyboard and receive it with a variable.
Use the switch statement to judge
Output the corresponding statement.
Practice:
The code is as follows (example):
Public class Demo3 {public static void main (String [] args) {/ / do not like ginger, do not be jealous / / enter the number of weeks on the keyboard and receive it with a variable; Scanner sc=new Scanner (System.in); System.out.println ("Please enter the day of the week:"); int week=sc.nextInt (); / / use the switch statement to judge Switch (week) {case 1: System.out.println ("Today's plan is: run!") ; break; case 2: System.out.println ("Today's plan is: mountain climbing!") ; break; case 3: System.out.println ("Today's plan is: swimming!") ; break; case 4: System.out.println ("Today's plan is: cycling!") ; break; case 5: System.out.println ("Today's plan is boxing!") ; break; case 6: System.out.println ("Today's plan is aerobics!") ; break; case 7: System.out.println ("Today's plan is: rest!") ; break; default: System.out.println ("entered the wrong day of the week!") ; break;}} these are all the contents of this article entitled "how to achieve weight loss Planning Program in java". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!