- 1
guys, is there someone that can help me with my coding?
I have a few problems with my coding and have absolutely no idea what to do to fix it. Basically I need to write a BMI calculator that uses 4 functions namely 1. "getData" which prompts and returns a users weight and height. 2. "calcBMi" to calculate the BMI using the formula bmi=weight/(height * height). 3. "displayFitnessResults" to display the bmi and weight status. Bmi < 18.5 - Underweight, bmi >= 18.5 && bmi <= 24.9 - Healthy, bmi >=25 && bmi <= 29.9 - Overweight, bmi >= 30 - Obese. 4. Main function
66 Antworten
+ 4
Of course
+ 4
I've got a question to 7, how many % is needed for each mark?
+ 4
Yes. I should end it soon, I've got only 2 fuctions to write.
+ 4
Okay, I tought it would be easier, but I faced many errors, most of them was caused by SoloLearn's compiler which has too less memory (I suppose). I can show you what I made and I will finish it tomorrow, better compile it in code blocks.
https://code.sololearn.com/ci2GI5aiWBun/?ref=app
+ 4
Yeah, that's beacuse I changed code while before, and I'm still getting segmentation fault. I gonna do it on Code Block, so I will fix it faster.
+ 4
Now it works. Give me a while, I'll send you code.
+ 4
Why are you unable to untag you form post? If it's beacuse I mentioned you I can just edit it
+ 4
It was a message to man who deleted his post, not you :D beacuse he was still getting nofications
+ 4
If you wanna enter every mark separately change getMarks to that:
void getMarks(int (&marks)[6], string subjects[6]){
for(int i = 0; i < 6; i++){
cout<<"Enter your marks for " << subjects[i] << endl;
do{
cin >> marks[i];
}while(marks[i] < 0 || marks[i] > 100);
}
}
And i main:
getMarks(marks, subjects);
+ 4
Everything works, now it's only about changing the look of output.
+ 3
I changed formula to w(h*h/10000) so you can input height in cm. If you want to enter it in meters remove '/10000' and change 'int' types to 'float'.
https://code.sololearn.com/c0QcsEuFqlsl/?ref=app
+ 3
You're sure. I corrected it.
+ 3
On SoloLearn you can enter values only one time, before the whole output.
Normally you could do it like that:
cout<<"enter weight";
cin>>w;
cout<<"enter height";
cin>>h;
+ 3
Edit fuction getData:
void getData(float &w, float &h)
{
cout << "Please enter your weight in Kilograms: " << endl;
cin >> w;
cout << "Please enter your height in Meters: " << endl;
cin >> h;
}
Then delete this from main:
cout << "Please enter your weight in Kilograms: " << endl;
cin >> w;
cout << "Please enter your height in Meters: " << endl;
cin >> h;
+ 3
So main should look like that:
int main() {
float weight, height;
getData(weight, height);
float bmi = calcBMI(weight, height);
string fat = displayFitnessResults(bmi);
cout << setprecision(3) << "Your weight is "<< weight << "kg and your height is " << height << "m." << endl <<"Your BMI is "<< bmi << "." << endl << fat;
return 0;
}
+ 3
For real about 1 year, but I have been starting when i was 13, maybe 14.
+ 3
Learning is sufficient reward for me ;) Give me only some time
+ 3
I was learning from polish website about c++ (a few free courses, about libs too), but SoloLearn is good. Beside the lessons you have challenges, quizes etc. so when you know syntax you can learn how to code from the others. It's easier then.
+ 3
Example of output:
Enter your name:
namee
Enter your surname:
sur
Enter your school name:
sch
Enter your marks:
15
49
99
100
78
89
Name: namee
Surname: sur
School Name: sch
Student passed 12 grade.
Student's average mark is 71 6 B
He isn't distincted.
Your best mark is 100
Your worst mark is 15
Marks:
English - 15 1 FF
Mathematics - 49 3 E
Life Orientation - 99 7 A
History - 100 7 A
Computer Literacy - 78 6 B
Geography - 89 7 A
Distincted subjects:
Life Orientation
History
Computer Literacy
Geography
Process returned 0 (0x0) execution time : 61.110 s
Press any key to continue.
Code(something, I suppose e-mail, put invisible signs instead of tabs, but it compiles in code blocks):
https://code.sololearn.com/cJlehyPrJ6Pd/?ref=app
+ 3
Okay, I can do that.