![]() ![]() He number you get is the number of daily calories you need in order to maintain your current weight. Very active. If you take part in hard exercise six to seven days per week, multiply your BMR by 1.725.Įxtra active. If you engage in very hard exercise six to seven days per week or have a physical job, multiply your BMR by 1.9. Moderately active. If you moderately exercise three to five days per week, multiply your BMR by 1.55. Lightly active. If you lightly exercise one to three days per week, multiply your BMR by 1.375. Sedentary: If you get little or no exercise, multiply your BMR by 1.2. To include the number of calories you burn during daily activities based on your lifestyle, use the following multiplications: This will make sure that you allow for the extra calories needed for things like walking around, playing sports, training and rebuilding muscle through hypertrophy. It requires that the else be there to close the then block.Once you’ve got your BMR, you need to multiply it by your activity level. That's true, but note that that kind of setup essentially enforces a similar standard. So you have to look forward to find out if you're done or not. The same symbol closes the then block and terminates the statement. Some will point out that this is a weakness in C-style languages. Now I know immediately that the } isn't ending the control structure, just the first then block. But what if we always write it like this: if (commandString = "BMI") But in reality, somewhere down the page, there's an else waiting to start things all over again. User has to input their height in centimeters (float)Ĭould become char gender = inputGender() ĭon't mislead me if (commandString = "BMI") std::cout > value Īnd now we can reuse this function. If you're going this far, you might as well go ahead and create a function for this. You may have already seen Why is “using namespace std ” considered bad practice? Use functions not blocks // User has to input their weight in kilograms (float) ![]() Gets called at the start - all other functions have to be written before it so the compiler knows of them!Ĭout << "Welcome to my first program - Romans Fitness Tools!" << endl << endl } while (commandString != "BMI" || commandString != "BMR") // Update everytime a new possible commandString is introduced If no valid tool is called let the user choose againĬout << "Enter a valid input for a tool you want to use!" << endl If user input is "BMR" open the BMRCalculator If user input is "BMI" open the BMICalculator All available tools in main - update everytime a new tool is addedĬout << "To calculate your BMI (Body Mass Index) type 'BMI'" << endl Ĭout << "To calculate your BMR (Basal Metabolic Rate) type 'BMR'" << endl Ĭout << "To exit the program type 'EXIT'" << endl ![]() User has to input their weight in kilograms (float)īMR = 10 * weightInKilograms + 6.25 * heightInCentimeters - 5 * ageInYears + 5 īMR = 10 * weightInKilograms + 6.25 * heightInCentimeters - 5 * ageInYears - 161 Ĭout << "Your BMR (Basal Metabolic Rate) is: " << BMR << endl Ĭout << "This is how much calories your body needs to maintain itsself." << endl If the input (char) isn't either 'M' or 'F' repeat until it is User has to input their gender (male M or female F) (char) Loops as long as cin fails (if input is NOT of type int) HeightInMeters = heightInCentimeters / 100 īMI = weightInKilograms / (heightInMeters * heightInMeters) Converts heightInCentimeters to heightInMeters for calculating the BMI User has to input their height in centimeters (float) Loops as long as cin fails (if input is NOT of type float) (Also open to any suggestions if I have any "bad code" or already some bad practices.) #include "stdafx.h" (I also eventually want to be able to output certain variables into a textfile and if possible input them everytime I start the program or when I need them.) So this is my project at the moment (pretty simple so far): I want to learn this from the beginning so it won't be a problem later. cpp files but I heard it is considered bad practice. I could not yet find out how I should use header and source files to still have my project work - I first thought I could just include. I am pretty new to coding and I wanted to know how to use header and source files to organize a C++ project. ![]()
0 Comments
Leave a Reply. |