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
|
#include "iostream"
#include "conio.h"
#include "string"
#include "time.h"
#include "windows.h"
#include "stdio.h"
#include "math.h"
using namespace std;
float square (float x)
{
float result1 = x*x;
return result1;
}
float cube (float x)
{
float result2 = x*x*x;
return result2;
}
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x; coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
void setColor(int x)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);
}
void main()
{
char key=' ';
int i, x=0,p=0, d=1, k=0;
float j;
string Username, Answer1, Answer2, option[10];
option[1] = "find the square of a number";
option[2] = "find the cube of a number";
option[3] = "play tic tac toe";
option[4] = "do some second degree equations";
option[5] = "get asked some questions";
cout<<"Hello, welcome to noobcraft"<<endl;
cout<<"Plase write your username"<<endl;
getline (cin, Username);
cout<<"Your selected username is "<<Username<<endl;
cout<<"You sure you want to continue?";
getline (cin, Answer1);
if (Answer1 == "Yes" || Answer1 == "yes" || Answer1 == "Y" || Answer1 == "Yeh" || Answer1 == "ye" || Answer1 == "y")
{
system ("CLS");
cout<<"Welcome, "<<Username<<". This program is just a way of me trying to remember what i learned so far. And you will help me."<<endl;
cout<<"Now, please tell me which one of this things you want to do."<<endl;
while (k == 0)
{
for (i=0; i<5; i++)
{
cout<<i+1<<"-I want to "<<option[i+1]<<endl;
}
cout<<"Write the number of the option";
cin>>p;
if (p = 1)
{
while (d == 1)
{
system("CLS");
cout<<"you've chosen option "<<p<<","<<option[p]<<endl;
cout<<"Write the value of the number: ";
cin>>j;
cout<<square(j)<<endl;
Sleep(20);
cout<<"Do you want to 1.Find the value of another number or 2.Do something else?"<<endl;
cin>>d;
if (d = 2)
{
system ("CLS");
k=0;
d==2;
}
}
}
if (p == 2)
{
k++;
system("CLS");
cout<<"you've chosen option "<<p<<","<<option[p]<<endl;
}
if (p == 3)
{
k++;
system("CLS");
cout<<"you've chosen option "<<p<<","<<option[p]<<endl;
}
if (p == 4)
{
k++;
system("CLS");
cout<<"you've chosen option "<<p<<","<<option[p]<<endl;
}
if (p == 5)
{
k++;
system("CLS");
cout<<"you've chosen option "<<p<<","<<option[p]<<endl;
}
}
}
}
|