CS106A assignment3 --problem1 AerobicExercise

    /* 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)");
            }
        }
    }
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 可是,很遗憾,我却不能透过盒子看见小羊。我大概有点和大人们差不多。我一定是变老了。 他很有见识地说:“猴面包树在长...
    focus_talent阅读 658评论 0 0
  • 这一篇博客主要记录我在开发中遇到的一些诡异的问题。记录在这里,当下次自己遇到的时候可以马上找到解决的方案。同时也想...
    Laughingg阅读 532评论 0 1
  • 车前已是万家灯火 车后也是万家灯火 拥堵的高速路 车灯闪烁 与路边的霓虹 都是迷离的河流 天越发蓝了 深邃辽阔 西...
    读云轩札记阅读 150评论 0 0
  • 愿以此功德。庄严佛净土。 上报四重恩。下济三途苦。 若有见闻者。悉发菩提心。 尽此一报身。同生极乐国。 南无大悲观...
    天牛and恩恩成长记阅读 226评论 0 3