Thread: help

  1. #1
    Registered User
    Join Date
    Jul 2010
    Posts
    1

    Smile help

    I am working on if statement insurace policy. When i use debugging the if statement only just ask me what gender are you? I enter the answer and then it gave me all the answer to the if statement when all the questions havent been answer. Can anybody give me clues or suggestions of how to fix my if statement problems. Here is the if statement below.


    //Stafford Lewis

    #include <iostream>
    #include <math.h>
    using namespace std;
    int main()
    {
    double Female, Male;
    int age;





    double policyrate;

    cout<<"Enter your gender (Female or Male):"<<endl;
    cin>> Male,Female;
    cout<<"Male,Female "<<Male,Female<<endl;

    cout<<"Enter your age:"<<endl;
    cin>> age;
    cout<<"age "<<age<<endl;




    if(gender='Male')
    if (age<21)

    policyrate= 0.05;


    else


    policyrate= 0.035;

    else if (gender='Female')
    if (age<21)

    policyrate= 0.04;


    else

    policyrate= 0.03;


    return 0;



    }
    Last edited by lakers916; 07-22-2010 at 04:35 AM.

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    You could benefit greatly from reading the forum announcements and stickies. Knowing how to actually ask a question wouldn't hurt either.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

  3. #3
    Registered User
    Join Date
    Dec 2007
    Posts
    2,675
    Your problems include not understanding scope and the use of
    Code:
    {}
    as well as the difference between = and ==.

Popular pages Recent additions subscribe to a feed