nest if statement with AND Problem

Having trouble with code not wanting to read my IF statement. Want to know why..
any help is appreciated.

#include <iostream>
#include <string>
using namespace std;

int main()
{
double commEarned = 0.00;
double valSale = 0.00;
double totalSale = 0.00;
double rate = 0.00;
char status;




cout << "What is your work status? Enter F(for Full) or P(for Part) "<< endl;
cin >> status;


cout << "what is the total amount of your sales?" << endl;
cin >> totalSale;

{
if (status == 'F' && totalSale < 10000000)

{
rate = .035;


if (status == 'F' && totalSale >= 10000000)
{

rate = .075;
}

if (status == 'P');
{
rate = .05;
}
}
}

//calculations

commEarned = totalSale*rate;
valSale = totalSale - commEarned;

cout << "Your status is: " << status << endl;
cout << "Commision earned:" " $ " << commEarned << endl;
cout << "The companies return:" "$" << valSale << endl;
cout << "Your rate is: " << rate << endl;


return(0);
}
I don't see any problem, i tried your code and everything went fine for me...

Edit now i see a point where the code will never go:
1
2
3
4
5
6

if (status == 'P');
{
    rate = .05;
}


This if must be outside the outern one, otherwise that code will never be executed because you are inside this other if:
1
2
3
4
5

if (status == 'F' && totalSale < 10000000)
{
   rate = .035;
...
Last edited on
You have a problem with this if statement:
1
2
3
4
if (status == 'P');
{
    rate = .05;
}

Note the ; on the first line. That terminates the if statement. The statements between the {} will be executed unconditionally. Remove the ;

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post.
http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.


You helped out greatly thank you very much...
Topic archived. No new replies allowed.