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
|
#include <iostream>
using namespace std;
int Auth();
void Calculator();
void beer();
double add(double x,double y)
{
return x+y;
}
double sub(double x,double y)
{
return x-y;
}
double mult(double x,double y)
{
return x*y;
}
double div(double x,double y)
{
return x/y;
}
string username, password;
int main()
{
Auth();
string choice;
while(choice !="Calculator"&&choice !="Beer")
{
cout<<"Pick between Calculator and Beer."<<endl;
getline(cin,choice,'\n');
}
if(choice =="Calculator")
{
Calculator();
}
if(choice =="Beer")
{
beer();
}
}
int Auth()
{
cout<<"Enter username: ";
cin>>username;
cout<<"Enter password: ";
cin>>password;
if((username=="Colin") && (password=="jasmine69420"))
{
cout<<"Welcome to the program!"<<endl;
}
else
{
return 0;
}
}
void Calculator()
{
double x,y;
string operation;
cout<<"Select either +, -, *, /"<<endl;
cin>>operation;
cout<<"Pick number 1: ";
cin>>x;
cout<<"Pick number 2: ";
cin>>y;
if(operation=="+")
{
cout<<"The result is: "<<add(x,y)<<endl;
}
if(operation=="-")
{
cout<<"The result is: "<<sub(x,y)<<endl;
}
if(operation=="*")
{
cout<<"The result is: "<<mult(x,y)<<endl;
}
if(operation=="/")
{
cout<<"The result is: "<<div(x,y)<<endl;
}
}
void beer()
{
for(double bottle=99; bottle > 0; bottle--)
{
cout << bottle << " bottles of beer on the wall, " << bottle << " bottles of beer." << endl <<
"Take one down, pass it around, " << bottle - 1 << " bottles of beer on the wall...\n";
}
}
|