From dfb8658f21e57066ecd34701820172be518fa607 Mon Sep 17 00:00:00 2001 From: ting Date: Wed, 19 Jul 2017 11:24:03 +0000 Subject: [PATCH 1/2] done --- 2017-Greatroom-gin | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 2017-Greatroom-gin diff --git a/2017-Greatroom-gin b/2017-Greatroom-gin new file mode 100644 index 0000000..bba0697 --- /dev/null +++ b/2017-Greatroom-gin @@ -0,0 +1,22 @@ +//黃競霆 + + +var readline = require('readline'); + +var rl = readline.createInterface({ + input: process.stdin, + output: process.stdout +}); + +function getMessage(number){ + console.log('the BMI is ',number); +} + +rl.question('Enter height: ',function(height){ + rl.question('Enter weight: ',function(weight){ + var BMI = parseFloat(weight)/(parseFloat(height)*parseFloat(height)); + getMessage(BMI) + + rl.close; + }); +}); From 33c1665ca860e524da92d84de4344aef5407274f Mon Sep 17 00:00:00 2001 From: ting Date: Wed, 19 Jul 2017 15:23:20 +0000 Subject: [PATCH 2/2] js_hw1 --- 2017-Greatroom-gin | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/2017-Greatroom-gin b/2017-Greatroom-gin index bba0697..0b61c9a 100644 --- a/2017-Greatroom-gin +++ b/2017-Greatroom-gin @@ -8,15 +8,31 @@ var rl = readline.createInterface({ output: process.stdout }); -function getMessage(number){ - console.log('the BMI is ',number); +function getMessage(height,weight){ + var BMI = parseFloat(weight)/(parseFloat(height)*parseFloat(height)); + if(BMI < 18.5 ) + console.log("體重過輕"); + else if( 18.5<= BMI < 24) + console.log("正常範圍"); + else if( 24 <= BMI < 27) + console.log("過重"); + else if( 27<= BMI < 30) + console.log("輕度肥胖"); + else if( 30<= BMI < 35) + console.log("中度肥胖"); + else + console.log("重度肥胖"); +} + +function getBMI(height,weight){ + var BMI = parseFloat(weight)/(parseFloat(height)*parseFloat(height)); + console.log("my BMI is ",BMI); } rl.question('Enter height: ',function(height){ rl.question('Enter weight: ',function(weight){ - var BMI = parseFloat(weight)/(parseFloat(height)*parseFloat(height)); - getMessage(BMI) - + getBMI(height,weight) + getMessage(height,weight) rl.close; }); });