- 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

19th Sep 2018, 2:01 PM
Ruben Oberholzer
Ruben Oberholzer - avatar
66 Answers
+ 4
Of course
19th Sep 2018, 5:51 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 4
I've got a question to 7, how many % is needed for each mark?
19th Sep 2018, 8:36 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 4
Yes. I should end it soon, I've got only 2 fuctions to write.
19th Sep 2018, 8:45 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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
19th Sep 2018, 10:09 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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.
20th Sep 2018, 3:39 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 4
Now it works. Give me a while, I'll send you code.
20th Sep 2018, 4:17 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 4
Why are you unable to untag you form post? If it's beacuse I mentioned you I can just edit it
20th Sep 2018, 4:50 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 4
It was a message to man who deleted his post, not you :D beacuse he was still getting nofications
20th Sep 2018, 5:40 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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);
20th Sep 2018, 7:06 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 4
Everything works, now it's only about changing the look of output.
20th Sep 2018, 7:31 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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
19th Sep 2018, 3:09 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 3
You're sure. I corrected it.
19th Sep 2018, 3:37 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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;
19th Sep 2018, 4:49 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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;
19th Sep 2018, 5:01 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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; }
19th Sep 2018, 5:02 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 3
For real about 1 year, but I have been starting when i was 13, maybe 14.
19th Sep 2018, 5:12 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 3
Learning is sufficient reward for me ;) Give me only some time
19th Sep 2018, 6:25 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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.
19th Sep 2018, 6:53 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 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
20th Sep 2018, 4:27 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 3
Okay, I can do that.
20th Sep 2018, 7:12 PM
Aleksander Szczepura
Aleksander Szczepura - avatar