473,320 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Help creating a loop.

I found the answer,
but thanks for all the
help!


For my c++ class I have to make a small win32 console program that
calculates body mass index. The user will enter in a their first and
last initial then their height, then weight. After calculating the
bmi the program tells the person if they are fat or not. I need to
loop this portion of the program until the user enters in an * for
the first initial, and if they enter it in on the first time the
program must end. I am stuck any suggestions? Below is what I have so
far.
#include <iostream>
using namespace std;

void main()
{
// declare variables
char FirstInitial = 0, SecondInitial = 0;
int height, weight;
double inTo_m, lbTo_kg, meters_squared, bmi;

cout << "Programed By jfufjsi jisoslent" <<
endl << endl;
cout << "Type an (*) for the first initial to
exit." << endl;
// input
cout << "Enter your first and last initial: ";
cin >> FirstInitial;
cin >> SecondInitial;
cout << "Enter your height in inches: ";
cin >> height;
cout << "Enter your weight in pounds: ";
cin >> weight;
cout << endl << endl;

// convert height in inches to meters squared
inTo_m = (height * 2.54) / 100;
meters_squared = inTo_m * inTo_m;

// convert weight in pounds to kilograms
lbTo_kg = (weight * 16) * .0283495231;

// find BMI
bmi = lbTo_kg / meters_squared;

// sets the places after the decimal and display initials and bmi
cout.precision(2);
cout.setf(ios::fixed);
cout << FirstInitial << ". " <<
SecondInitial << ". "
<< "your BMI is : "
<< bmi << endl << endl;

// if/else if loop to test for bmi weight match
if (bmi < 18.5)
{
cout << " You are underweight" << endl
<< endl << endl;
}
else if (bmi >= 18.5 && bmi < 25)
{
cout << " You are a normal weight" <<
endl << endl << endl;
}
else if (bmi >= 25 && bmi < 30)
{
cout << " You are overweight" << endl
<< endl << endl;
}
else if (bmi >= 30)
{
cout << " You are obese" << endl
<< endl << endl;
}
}

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 17 '05 #1
0 1158

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: ArShAm | last post by:
Hi there Please help me to optimize this code for speed I added /O2 to compiler settings I added /Oe to compiler settings for accepting register type request , but it seems that is not allowed...
9
by: Dom Boyce | last post by:
Hi First up, I am using MS Access 2002. I have a database which records analyst rating changes for a list of companies on a daily basis. Unfortunately, the database has been set up (by my...
0
by: Sarah | last post by:
Hi, I have an Access database of about 1000 records. I am trying to use asp to loop through the record set one at a time, creating the html code for a web page. I would like to save the actual...
1
by: steven | last post by:
I am creating some financial reports in Access 2000, and I am having problem that I can't resolve. The report sorts information first by vendor, then by budget line number. It generates the...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
4
by: Tarun Mistry | last post by:
Hi all, I have posted this in both the c# and asp.net groups as it applies to both (apologies if it breaks some group rules). I am making a web app in asp.net using c#. This is the first fully OO...
3
by: mslyman | last post by:
Hi, I could do with some help. I have this XML. <region> <region_code>567</region_code> <store> <store_code>345</store_code> <dept> <dept_code>32</dept_code> </dept>
6
by: kberry | last post by:
I am clearing Textboxes on a form... this is loop I have came up with but was wondering if it can be shorter or not as long... Can anyone help? Dim controlOnForm As Control 'Places a control...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
14
by: bcap | last post by:
Hello, I really would apprciate help! =) What I want to do is be able to change the status of mulitple records using a drop down and a checkbox. I have a drop down called "ChangeStatus"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.