Thread: Need help with my simple If statement & Boolean (Noob sos)

  1. #16
    Registered User
    Join Date
    Oct 2013
    Posts
    20
    Huh.. that is weird. Although I've noticed something just now. When I paste my code in the "Quick Reply" and click "Go Advanced" (in order to preview) it makes my spacebars disappear for some reason (As is the reason why "elseif" shows together.)
    Also how are there any duplicates? All the couts have a purpose. It might seem that "Your both crazy old" is repeated but that's only so that if they are the same age, it adds "And" to the previous sentence, "Your both the same age". (Sorry if it's obvious and I don't see it.. Still a noob.. -_-)


    As for my IDE I'm using Xcode. Will now try and paste code from a online converter. (I don't think macs have notepad and text edit still uses font.)

    Code:
    #include <iostream>
    #include <string>
    
    
    using namespace std;
    
    
    int main ()
    
    
    {
        string name; // x
        string name_2; // y
        int x;
        int y;
        
        cout << "Hello User.. This program intend's to ask for the age and name of 2 people\n";
        
        cout << "Please enter the first name:\n";
        getline(cin, name, '\n');
        
        cout << "Good.. now enter the age of " << name << ":\n";
        cin >> x;
        cin.ignore();
        
        cout << "Next I need you to enter the name of person number 2:\n";
        getline(cin, name_2, '\n');
        
        cout << "Alright.. now finally please enter the age of " << name_2 << ":\n";
        cin >> y;
        
        if (x > y)
            cout << name << " is older than " << name_2 << "\n";
        else if (y > x)
            cout << name_2 << " is older than " << name << "\n";
        else if (x == y)
            cout << "You're both the same age!!\n";
     
        
        if (( x > 100 && y > 100) && x == y)
            cout << "And You're both crazy old!!\n";
        else if ( x > 100 && y > 100)
            cout << "You're both crazy old!!!\n";
    
    
    }
    Last edited by Jonathan002; 10-06-2013 at 03:16 AM.

  2. #17
    Registered User
    Join Date
    Oct 2013
    Posts
    20
    I think the plain text is working!!

  3. #18
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    Posts
    485
    You spelt "intends" wrong.

  4. #19
    Registered User
    Join Date
    Oct 2013
    Posts
    20

    Fixed my spelling!

    After reading feedback.. I've decided to fix spelling of intends.

    Code:
    #include <iostream>
    #include <string>
    
    
    using namespace std;
    
    
    int main ()
    
    
    {
        string name; // x
        string name_2; // y
        int x;
        int y;
        
        cout << "Hello User.. This program intends to ask for the age and name of 2 people.\n";
        
        cout << "Please enter the first name:\n";
        getline(cin, name, '\n');
        
        cout << "Good.. now enter the age of " << name << ":\n";
        cin >> x;
        cin.ignore();
        
        cout << "Next I need you to enter the name of person number 2:\n";
        getline(cin, name_2, '\n');
        
        cout << "Alright.. now finally please enter the age of " << name_2 << ":\n";
        cin >> y;
        
        if (x > y)
            cout << name << " is older than " << name_2 << "\n";
        else if (y > x)
            cout << name_2 << " is older than " << name << "\n";
        else if (x == y)
            cout << "You're both the same age!!\n";
     
        
        if (( x > 100 && y > 100) && x == y)
            cout << "And You're both crazy old!!\n";
        else if ( x > 100 && y > 100)
            cout << "You're both crazy old!!!\n";
    
    
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a simple question (Noob)
    By MishaMish in forum C++ Programming
    Replies: 2
    Last Post: 01-26-2011, 01:24 AM
  2. Replies: 2
    Last Post: 04-25-2010, 10:07 AM
  3. Replies: 3
    Last Post: 09-12-2005, 09:08 AM
  4. Noob here...a simple question.
    By The_Mayor in forum C Programming
    Replies: 4
    Last Post: 06-08-2005, 12:48 AM
  5. Simple boolean problem
    By larry in forum C++ Programming
    Replies: 9
    Last Post: 10-13-2001, 08:49 AM

Tags for this Thread