Coding Lab

I am working on a continuous lab assignment and I was wondering if someone could help me with the coding.


HERE IS THE ASSIGNMENT:
Not all people are lightly active, and people who exercise may need to eat more. This section adjusts for a person’s activity level and then adjusts the output of the BMR and the amount of food that can be eaten. To do this you need to know:
How active the user is and how to adjust the output. Therefore, in addition to the input you request from the user in Phase 1, ask the user if he or she is a/an:
• Non-exerciser--sedentary (‘n’)
• Infrequent exerciser--exercise occasionally (‘i’)
• Frequent exerciser--exercise 3-4 days per week (‘f’)
• Every day exerciser (‘e’)
The character next to each choice represents the character the user should input for that choice. Each choice modifies the original BMR calculation by:
• Non-exerciser -- Decrease original calculation by 5%
• Infrequent exerciser -- Increase original calculation by 30%
• Frequent exerciser -- Increase original calculation by 40%
• Every day exerciser -- Increase original calculation by 50%
Your modifications to the original BMR calculation MUST be in a switch statement.

I am confused with what part of my previous work that I will use in this section. my teacher likes us to complete this in phases that is continuous.

HERE IS MY PREVIOUS WORK

#include <iostream>
using namespace std;
int main()
{
char gender;
int age, number_of_cookies;
double weight, height, BMR, total_cookies;
cout << "Please provide the basic information" << endl;
cout << "Male or female (m or f) ?";
cin >> gender;
cout << "Age in years?";
cin >> age;
cout << "Weight in pounds?";
cin >> weight;
cout << "Height in inches?";
cin >> height;
if (gender == 'f' || 'F' || age >= 65)
{ //Yset gender to some value m or f you need
//to compare to that previously set value, not another word like 'female'
BMR = 1.375 * (655 + (4.3 * weight) + (4.7 * height) - (4.7 * age));
// Use BMR of woman or man with age >=65 years//
}
else //Use BMR of man age<65years
{ //Make sure you are using brakets {} for this not ()
BMR = 1.375 * (66 + (6.3 * weight) + (12.9 * height) - (6.8 * age));
}
total_cookies = BMR / 230; //calculate the number of cookies that can be eaten
printf("BMR = %.2f\n", BMR);
// print bmr with two decimal points of precision
//| That '%.2f' is telling the program to print '.2' two decimal places & '%f' in a decimal format.

cout << "number of cookies that can be eaten = " << total_cookies << endl;
return 0;
}


With these two things posted what can I use from the last code in my new assignment?
Your "previous work" looks like copy-paste of what an another forum user wrote to you in your earlier thread. It even contains the errors. In other words, it does not do what it should.

It would be really nice and useful, if you would use the code tags. See http://www.cplusplus.com/articles/jEywvCM9/


Lets assume that you have already calculated the BMR correctly.
You had asked the user about activity along the other input, so you have that information in a variable.

Now add a switch statement. See http://www.cplusplus.com/doc/tutorial/control/
Each proper case will modify the BMR appropriately.

After the switch you can show BMR and calculate cookies, just like before.
closed account (zCk2y60M)
Keskiverto,

Please refrain from commenting in this manner in the future. This thread was started to help believedancer with their programming problem... if you aren't contributing to that then why post?

Based upon your profile, it would seem to me that you have enough programming experience to help this user with the problem... Please put your talent(that many on cplusplus are trying to learn) to good use.


Thanks mate
beginnerben,

Strange coincidence that your only other post besides this bizarre rant is on a problem identical to OP's. keskiverto offered far more help in his post than you did in yours, and did so in spite of evidence that the OP is trying to get the forum to do his homework for him.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
using namespace std;
int main()
{
char gender;
int age, number_of_cookies;
double weight, height, BMR, total_cookies;
cout << "Please provide the basic information" << endl;
cout << "Male or female (m or f) ?";
cin >> gender;
cout << "Age in years?";
cin >> age;
cout << "Weight in pounds?";
cin >> weight;
cout << "Height in inches?";
cin >> height;
if (gender == 'f' || 'F' || age >= 65)
{	//Yset gender to some value m or f you need 
//to compare to that previously set value, not another word like 'female'
BMR = 1.375 * (655 + (4.3 * weight) + (4.7 * height) - (4.7 * age)); 
// Use BMR of woman or man with age >=65 years//
}
else	//Use BMR of man age<65years
{	//Make sure you are using brakets {} for this not ()
BMR = 1.375 * (66 + (6.3 * weight) + (12.9 * height) - (6.8 * age));	
}
total_cookies = BMR / 230;	//calculate the number of cookies that can be eaten
printf("BMR = %.2f\n", BMR);
// print bmr with two decimal points of precision 
//| That '%.2f' is telling the program to print '.2' two decimal places & '%f' in a decimal format.

cout << "number of cookies that can be eaten = " << total_cookies << endl;
return 0;
}



Here is the work in the code format! Is anyone able to do this? I'm having trouble completing the assignment as well... :/
If someone wouldnt mind helping me, thatd be awesome! This assignment, for me at least, is due in 2 hours. I have specific questions!!

How do I start this add on? I always tend to have trouble with the continuation of old programs like this

I cant seem to grasp the request for user input

Also I am wondering what would be the most effective way to build the...

Non-exerciser--sedentary (‘n’)
• Infrequent exerciser--exercise occasionally (‘i’)
• Frequent exerciser--exercise 3-4 days per week (‘f’)
• Every day exerciser (‘e’)

... portion with the corresponding BMR recalculations.

Someone please help!!
@TackyTechyy

One problem is this line.
if (gender == 'f' || 'F' || age >= 65)

It should be like this..

if (gender == 'f' || gender == 'F' || age >= 65)

I cant seem to grasp the request for user input

The earlier program takes four user inputs: gender, age, weight, height. The new program has to do one more: activity.
Topic archived. No new replies allowed.