อัปเดต README และเพิ่ม BMI Calculator

This commit is contained in:
Late Night Defender 2023-04-03 00:48:18 +07:00
parent 6945d42f73
commit 50bbb4ec55
11 changed files with 141 additions and 90 deletions

View file

@ -0,0 +1,34 @@
# bmi-calculator-cli
bmi-calculator-cli นี้ เป็นโปรแกรมสำหรับคำนวณค่า BMI ที่เขียนในภาษา C++
โดยจะรับค่าน้ำหนักในหน่วยกิโลกรัม ส่วนสูงในหน่วยเมตร นำไปคำนวณค่า BMI ด้วยสูตร
![BMI Formula](formula.png)
เมื่อได้ค่า BMI ออกมาแล้ว นำมาเทียบเกณฑ์ดังนี้
ต่ำกว่า 18.5 น้ำหนักต่ำกว่าเกณฑ์
18.5 - 24.9 ปกติ
25.0 - 29.9 สูงกว่ามาตรฐาน
ตั้งแต่ 30.0 ขึ้นไป อ้วนเกินไป
# ตัวอย่างการทำงานของโปรแกรม
![App example](example.png)
# วิธีติดตั้ง (Linux เท่านั้น)
1. Clone git นี้
`git clone https://gitlab.com/sashapgt/bmi-calculator-cli.git`
2. cd เข้าโฟลเดอร์ของ git นี้ แล้วสั่งติดตั้ง
`cd bmi-calculator-cli && sh install.sh`
3. เรียกใช้จากเทอร์มินัลได้เลย
`$ bmi-calculator-cli`

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

13
bmi-calculator-cli/install.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/sh
DIR=$HOME/.local/bin
APPNAME=bmi-calculator-cli
if [[ ! -d "$DIR" ]]
then
mkdir $DIR
echo "กำลัง Build และติดตั้ง $APPNAME ใน $DIR"
else
echo "กำลัง Build และติดตั้ง $APPNAME ใน $DIR"
fi
g++ -Wall -o "$DIR/$APPNAME" "main.cpp"

View file

@ -0,0 +1,23 @@
#include<stdio.h>
#include<math.h>
int main() {
float x,y,z;
printf("ความสูง (ในหน่วยเมตร) : ");
scanf("%f", &x);
printf("น้ำหนัก (ในหน่วยกิโลกรัม) : ");
scanf("%f", &y);
z = y/pow(x, 2);
printf("ค่า BMI ของคุุณคือ %.1f และอยู่ในเกณฑ์: ", z);
if(z<18.5){
printf("น้ำหนักต่ำกว่าเกณฑ์");
}
else if (z>=18.5&&z<25){
printf("ปกติ");
}
else if (z>=25&&z<30){
printf("สูงกว่ามาตรฐาน");
}
else printf("อ้วนเกินไป");
//return 0;
}