I did not see anywhere to post the Guessing Game, but this was a fun assignement.
#include <iostream>
using namespace std;
int main()
{
// string name;
// cout << "...and what is your name?";
// cin >> name;
// cout << createGreeting(name);
// game -create random number - pl2 guess random number
// too high or too low - guess again
// count tries
int randomnumber = rand() % 100 + 1; // create a random number from 1-100
cout << "Welcome the the Ivan guess a number game. Please guess a number from 1 to 100!" << endl;
int tries = 1;
int guess = 0;
while (guess != randomnumber){
cout << "Guess! ";
cin >> guess;
if (guess < randomnumber) {
cout << "Woops - too low. Try again." << endl;
}else if (guess > randomnumber) {
cout << "Too high. Try again. " << endl;
}
tries ++;
}
// added sass
string comment;
if (tries < 10) {
comment = " - you are a superstar!";
} else if (tries > 30) {
comment = "Uhm.. That took you a long time.";
}
cout << "Great job you only took " << tries << " attempts!" << comment;
return 0;
}