All pastes #2090163 Raw Edit

montyc++

public text v1 · immutable
#2090163 ·published 2011-10-14 22:34 UTC
rendered paste body
#include <iostream>

using namespace std;


void guessAgeMultiplied(int age, int multiplier)
{
	int yourGuess=0;
	int repeat=0;

	do
{					
	                if (repeat >=1)
					cout << "Good try, but not quite!" << endl;
					else
{						cout << "Can you guess what multiplier was used to create the number below......?" << endl;
						cout << age * 10 << endl;
						cout << "Give it a try, I have faith in you!" << endl;
}
					 
					cin >> yourGuess;
					repeat += 1;
}	while(yourGuess != 10);
	if (repeat >1)
		cout << "Fantastic! Only took " << repeat << " tries!";
	else
		cout << "Fantastic! Only took " << repeat << " try!\n ";

				

}

void guessAge(int age)
{
       int yourGuess=0;
       int repeat=0;
       do
       {
               if (repeat >= 1)
                       cout << "Not quite, try again!" << endl;
               else
                       cout << "Can you guess correct age?" << endl;
               cin >> yourGuess;
               repeat += 1;
       } while(yourGuess != age);
       if (repeat >1)
               cout << "You're right! It took you " << repeat << " tries!";
       else
               cout << "You're right! It took you " << repeat << " try!\n";
}
int main()
{
       int mycat=14;
       int yourcat=0;
       cout << "How old is your cat?" << endl;
       cin >> yourcat;
       if (mycat > yourcat)
       {
               cout << "My cat is " << mycat - yourcat << " years older than yours!\n";
               guessAge(mycat);
			   guessAgeMultiplied(mycat, 10);
			        }        
       else if (mycat < yourcat)
       {
               cout << "My cat is " << yourcat - mycat << " years younger than yours!\n";
			   guessAge(mycat);
			   guessAgeMultiplied(mycat, 10);		   
       }
       else if (mycat == yourcat)
       {
               cout << "My cat is the same age as yours!";
			   guessAgeMultiplied(mycat, 10);
       }
       system("pause");
       return 1;
}