Saturday
April 19, 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 ...
C++ - Can anyone help me with my c++ program? Its a program I have to write ...
Fund of programming 1 - Complete the following C++ program. The program should ...
C++ Programming - I have to redo programming exercise 5 of chapter 9 using ...
programming C++ - Write a program that reads test scores up to 30 into an array...
C++ Programming - Design and create a class named Stats that has an array of 12 ...
computer science - 9.10: Reverse Array Write a function that accepts an int ...
C++ - I have no idea how to construct this program. Any help is appreciated. ...
C++ - I am having trouble identifying the flaws in my code. I need to created a ...
programming - I need help in the TODO section. /** * Driver.cpp - This file ...

Search
Members