Thursday
August 28, 2014

Homework Help: C++ if else problem, please look

Posted by sonnytsn on Monday, January 24, 2011 at 5:50pm.

It compiles but it doesn't work. can you tell me what i did wrong?

//Sonny Hinh, variable program, assignment 2
#include <iostream>
using namespace std;

int main ()
{ char gender;
int age, bmi, dose1, dose2;
double dose3, dose4;
dose1 = bmi * 2;
dose2 = bmi * 2 + 13;
dose3 = bmi * 2 * .95;
dose4 = bmi * 2 + 13 * .95;
cout << "Enter age: ";
cin >> age;
cout << "Enter BMI: ";
cin >> bmi;
cout << "Enter sex (M or F): ";
cin >> gender;
if (gender == 'M')
{ if (age < 12)
{ cout << "\nDose is: " << dose1 << " units" << endl;
}
else
{ cout << "\nDose is: " << dose2 << " units" << endl;
}
}
else
{ if (age < 12)
{ cout << "\nDose is: " << dose3 << " units" << endl;
}
else
{ cout << "\nDose is: " << dose4 << " units" << endl;
}
}
system("PAUSE");
return 0;
}

Answer this Question

First Name:
School Subject:
Answer:

Related Questions

C++ Programming - Can any1 please fix this c++ source problem /*Circle Are ...
Fund of programming 1 - Complete the following C++ program. The program should ...
C++ - Can anyone help me with my c++ program? Its a program I have to write ...
Programing - Write a full program that reads in an arbitrary sequence of ...
C++ Programming - I have to redo programming exercise 5 of chapter 9 using ...
PLease Help Me IN Math - Problem: 25-x^2 6 ------ * --- 12 5-x What I Got: 5-x...
Computer Programming using python - Assume s is a string of lower case ...
computer science - ineed help with c++. i am using code blocks and i have a ...
programming C++ - Write a program that reads test scores up to 30 into an array...
computer science - 9.10: Reverse Array Write a function that accepts an int ...

Search
Members