help

This is a discussion on help within the C++ Programming forums, part of the General Programming Boards category; I am working on if statement insurace policy. When i use debugging the if statement only just ask me what ...

  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;



    }
    Attached Files Attached Files
    Last edited by lakers916; 07-22-2010 at 05:35 AM.

  2. #2
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,399
    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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21