Nested If’s

 Below is a sample on how to use nested If statements, the program works sort of, if anyone has input on how to get it function properly I would greatly appreciate it.

#include <iostream>
#include <string>

using namespace std;

int main()

   int age1, income, car; // declaring integers
   string make, work; // declaring strings for the program

   cout << “This program is designed to classifly\npeople into proper sterotyped categories\n”; // program title
   cout << “First you must enter your age\n”; // user input
   cin >> age1; // storing first variable

   cout << “second you must enter the amount of money you make per year\n”; // user input
   cin >> income; // storing second variable
   cout << “Third, you must state the make of your car\n”; // user input
   cin >> make; // storing third variable

   cout << “The fourth part of the program will distinguish\nwhat you do for work\n”; // user input
   cin >> work; // storing fourth variable

   if(make == “mercedes”)//specify about the car
      car = 1;
   if(make == “bently” )
   if(make == “acura”)
   if(make == “honda”)
   if(make == “chrystler”)
     // changing of string names complete

   if(age1<30) // if age is less than 30 years
      cout << “you are very nieve to this world, give it some time\n”; // output if less than 30 years old
      if(income< 30000) // if income is less than 30000 dollars
         cout <<“maybe you should enroll into college, or find a better job\n”; //output if income is less than 30000
         if(make == “mercedes” || make == “bently” || make == “acura” || make == “honda” || //(A) if specific cars are inputed
            make == “chrystler” || make == “gm” || make == “volkswagon” || make == “toyota”)
            cout << “you have good taste, seems like you drive a decent car\n”;//(A) output on specific cars
            case 1: cout <<“I see you drive a mercedes\n”; //specify about the car

            case 2: cout <<“I see you drive a bently\n”; //specify about the car

            case 3: cout <<“I see you drive a acura\n”; //specify about the car

            case 4: cout <<“I see you drive a honda\n”; //specify about the car

            case 5: cout <<“I see you drive a chrystler\n”; //specify about the car

            default: cout << “maybe you should get a better car\n”; //default if they dont enter the specific cars

            if(work == “engineer” || work == “teacher” || work == “machinist” || work == “programmer” || // caputure specific job titles
               work == “driver” || work == “manager” || work == “designer” || work == “assistant”)
               cout << “Looks like you on the right path with your career\n”; //output if job titles match
               cout << “society thinks that your job is not a decent job, maybe you should get a different one\n”;//output if job titles dont match


About Rant4u

A Revolution in Social Networking

Posted on March 2, 2012, in Uncategorized. Bookmark the permalink. Leave a comment.


Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: