/* The program is to give advice by the minutes of exercise during the week.
*
*/
import acm.program.*;
public class AerobicExercise extends ConsoleProgram {
/*represent the days of exercise whose time is longer than 30 and 40*/
private static int carHealthTimes = 0;
private static int bloHealthTimes = 0;
public void run() {
inputMinutes();
showAdvice();
}
/*input the minutes */
private void inputMinutes() {
for(int i = 1 ;i < 8; i++){
int value = readInt("How many minutes of asrobic Execrcise did you do on day "+i+":");
if (value >= 30) carHealthTimes ++;
if (value >= 40) bloHealthTimes ++;
}
}
private void showAdvice() {
println("Cardiovascular Health");
if (carHealthTimes >= 4){
println(" Good job,you have done enough exercise for cardiovascular exercise");
}else{
println(" You needed 30 or more minutes of aerobic exercise on at "+ (5-carHealthTimes) +" more day(s)");
}
println("Blood Health");
if (bloHealthTimes >= 2){
println(" Good job,you have done enough exercise for blood exercise");
}else{
println(" You needed 40 or more minutes of blood exercise on at "+ (3-bloHealthTimes) +" more day(s)");
}
}
}
CS106A assignment3 --problem1 AerobicExercise
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 这一篇博客主要记录我在开发中遇到的一些诡异的问题。记录在这里,当下次自己遇到的时候可以马上找到解决的方案。同时也想...