1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <limits>
using namespace std;
int main()
{
cout << " Hello, " << endl;
cout << " I am going to show you a number between 1-100. " << endl;
cout << " I would like you to tell me if it is a Perfect, Abundant, or Deficient. " << endl;
cout << " Press Enter to Continue " << endl;
cin.ignore(100, '\n');
int numRightGuesses = 0, numWrongGuesses = 0, pos = 0, neg = 0, score = 0;
{
pos+= numRightGuesses;
neg+= numWrongGuesses;
score+=numRightGuesses,numWrongGuesses;
}
srand(time(0));//Starts random number generator
int number = rand() % 99 + 1;//Using Modulus operator to isolate values 99+1
cout << number;
cin.ignore(100, '\n');
cout << " Is this number a Perfect, Abundant, or Deficient ? " << endl;
cout << " Make sure you use capitol letters when selecting!" << endl;
cout << " Press A if you think it's a PERFECT NUMBER" << endl;
cout << " Press B if you think it's a ABUNDANT NUMBER" << endl;
cout << " Press C if you think it's a DEFICIENT NUMBER" << endl;
char Guess;
cin >> Guess;
int rand,one = 1, sum = 0;
while (score < 10)
{
if(number % one == 0)
sum = sum + one;
one++;
}
if(sum == number && Guess == 'A') //added another condition
{
cout << "You are correct! This is a Perfect Number!";
int numRightGuesses;
}
else if (sum > number && Guess == 'B') //added another condition
{
cout << "You are correct! This is an Abundant Number!";
int numRightGuesses;
}
else if (sum < number && Guess == 'C') //added another condition
{
cout << "You are correct! This is a Deficient Number!";
int numRightGuesses;
}
else
{
cout << "Sorry, you are incorrect!";
int numWrongGuesses;
}
{
cout << numWrongGuesses << " Right" << endl;
cout << numRightGuesses << " Wrong" << endl;
}
return 0;
}
|