/* 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
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 这一篇博客主要记录我在开发中遇到的一些诡异的问题。记录在这里,当下次自己遇到的时候可以马上找到解决的方案。同时也想...