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 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
|
#include<iostream>
#include<cstring>
#include<iomanip.h>
using namespace std;
int main()
{
system("TITLE Orville .3");
char username[8];
char password[8];
char bday[8];
char doagain;
char z;
int x;
int y;
int numbergame1;
do//start of first do statment
{
cout << "Welcome, the reason iam going to use, username and things like that" << endl;
cout << "Is to test using something like string comparision" << endl;
cout << "Username is Orville, and Password is Rodgers and" << endl;
cout << "B-day is J101989." << endl;
cout << endl;
cout << "Username: " << endl;
cin >> username;
if (strcmp(username, "Orville")== 0){//start of my first if, "if username isnt orville end program"
}else{
cout << "Incorrect" << endl;
system("pause");
return 0;
}//end of entire if statement
cout << "Password: " << endl;
cin >> password;
if (strcmp(password, "Rodgers")== 0){//start of my first if, "if username isnt orville end program"
}else{
cout << "Incorrect" << endl;
system("pause");
return 0;
}//end of entire if statement
cout << "Birthday" << endl;
cin >> bday;
if (strcmp(bday, "J101989")== 0){//start of third, same thing.
}else{
cout << "Incorrect" << endl;
system("pause");
return 0;
}//end end of entire if statement
cout << "So i thought id try to make up a stupid lil game, lets play! :D" << endl;
cout << "Try to just guess the number i want" << endl;
cin >> numbergame1;
do//second do..while loop
{
bool go_on=1;
do
{
go_on=1;
if (numbergame1 < 5){
cin.clear();
cin.ignore(1000, '\n');
go_on=0;
cout << "Sorry Try Again!" << endl;
}
}while(!go_on);
do
{
go_on=1;
if (numbergame1 > 5){
cin.clear();
cin.ignore(1000, '\n');
go_on=0;
cout << "Sorry, Try again!" << endl;
}
}while(!go_on);
}while(numbergame1 !=5); //end of second do..while loop
if (numbergame1 == 5){
cout << "Good Job!" << endl;
}
cout << "So now we've done my little game" << endl;
cout << "Which is awesome because it means" << endl;
cout << "Im doing better in C++" << endl;
cout << "Back when i have more to add to this code" << endl;
cout << "Orville .3" << endl;
cout << "Lets try, doing simple math functions" << endl;
cout << "Lets get some numbers :) Any number, big or small will do" << endl;
cin >> x;
cout << "Great! Now lets get that second number. Your first number: " << x << endl;
cin >> y;
cout << "Ok, Lastly, we need an operation to do(+,-,/ or *) Your second number: " << y << endl;
cin >> z;
switch (z){
case '+':
cout << "The answer is: " << x << "+" << y << "=" << (x + y) << endl;
break;
case '-':
cout << "The answer is: " << x << "-" << y << "=" << (x - y) << endl;
break;
case '/':
cout << "The answer is: " << x << "/" << y << "=" << (x / y) << endl;
break;
case '*':
cout << "The answer is: " << x << "*" << y << "=" << (x * y) << endl;
break;
}
cout << "Congratulations" << endl;
cout << "Well what else can I do?" << endl;
cout << "Ill try to use some enums and classes in the next part" << endl;
cout << "Again?" << endl;
cin >> doagain;
}while (doagain=='y' || doagain=='Y'); //end of do..while statemnt
system("pause");
return 0;
}//end of main code
|