lundi 28 mars 2016

C++: Using Char for Conditional Variables

I need help adding to a program that categorized ages to find out whether or not an individual is eligible for a life insurance package. Rules are to add to a previous program that allows user to input age and then outputs whether they are a minor child, minor teenager, adult, or senior senior adult use char yes or no whether eligible. This rules to the enhancement will be to also determine illegibility. Bellow are the rules and the code so far.

age eligible 17 or under 'n' 18-90 'y' more than 90 'n' <------new enhancement rules Code:

//12 or under         minor child
//13 - 17             minor teenager
//18 - 64             adult
//65 or over      senior adult


#include <iostream>
using namespace std;
int main()
{
    const int MAX_CHILD = 12, MAX_TEEN = 17, MAX_ADULT = 64; MAX_ADULT_ALLOWED = 90;
    int age;


    cout << "How old are you?";
    cin >> age;
    // additional code goes here

    if (age <= MAX_CHILD)
        cout << "You're a minor child.\n";

    else if (age <= MAX_TEEN)
        cout << "You're a minor teenager.\n";

    else if (age <= MAX_ADULT)
        cout << "You're an adult.\n";

    else if
        cout << "You're a senior adult.\n";

    else (age <= MAX_ADULT_ALLOWED)



    //if (eligible == "y")
    //cout << "You are eligible for life insurance package.\n";
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire