Thread: Need help learning C++.

  1. #16
    Registered User
    Join Date
    Jan 2006
    Posts
    10
    I would have no clue how to do that.. xD

  2. #17
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    would you like a clue?

  3. #18
    Registered User
    Join Date
    Jan 2006
    Posts
    10
    indeed

  4. #19
    Super Moderater.
    Join Date
    Jan 2005
    Posts
    374
    Code:
    #include <iostream>
    
    using namespace std;
    		
    int main()
    {
      int age;
      char ans;
      
      do
      {
      
      
      cout<<"Please input your age : ";
      cin>> age;
      cin.ignore();
      
      
      
       
      if ( age < 5 || age == 5 ) {
         cout<<"Are you potty trained yet?!\n";
      }
      else if ( age > 5 && age < 12 || age == 12 ) {
              cout<<"Woo! You're maturing.\n";
              }
      else if ( age > 12 && age < 20 ) {
              cout<<"You're a teenager, welcome to hell.\n";
              }
      else if ( age > 21 && age< 30 ) {
              cout<<"Party it up, you can drink, your prolly in college, or just out of it. Have fun.\n";
              }
      else if ( age == 20 ) {
              cout<<" You are the ........tiest age ever. You are in college, alot of work.. and you can't drink yet. Hold int here one more year.\n";
              }
      else if ( age > 30 && age < 40 || age == 30 || age == 40) {
              cout<<"You are getting towards middle aged, start to settle down.\n";
              }
      else if ( age > 40 && age < 47 ) {
              cout<<"You're now middle aged. Get used to it.\n";
              }  
      else if ( age == 47 ) {
              cout<<"I love you mom!!!!!\n";
              }
      else if ( age > 100 || age == 100 ) {
              cout<<"Plan your funeral, make sure your will is correct, etc.\n";     
              }
      else if ( age > 47 && age < 60 ) {
              cout<<"You're getting up there in years!!!\n";
              }
      else if ( age > 60 || age == 60 && age < 100 ) {
               cout<<"You're old.\n";
               }
               
      cout<<"Continue (y/n)"<<endl;
      cin>>ans;
               
      }while(ans!='n');   
      cin.get();
    }
    If you need this explaining, then please ask.

  5. #20
    Registered User
    Join Date
    Jan 2006
    Posts
    10
    thanks i get it.

    Now that I'm done I was wondering if I wanted to give an answer like.

    "you are ___ (whatever they entered) years young."
    how would I do something like that?

  6. #21
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    Code:
    cout<<"you are "<< age << " years young."<< endl;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Machine Learning with Lego Mindstorms
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 14
    Last Post: 01-30-2009, 02:34 PM
  2. Best Approach for Learning
    By UCnLA in forum C Programming
    Replies: 5
    Last Post: 03-21-2008, 02:35 AM
  3. Need Help On a Simple Bank Program
    By oobootsy1 in forum C# Programming
    Replies: 9
    Last Post: 08-08-2005, 10:51 AM
  4. Fun Learning a New Language
    By UnregdRegd in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 09-30-2003, 10:03 PM
  5. Learning Rate Of C++
    By Krak in forum C++ Programming
    Replies: 27
    Last Post: 01-29-2003, 01:53 PM