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 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
|
#include <iostream>//Includes common functions and such
using namespace std;//Use the std namespace
int input;
int main()//Program entry point
//{ double x;
// double mult ( double x, double y );
// double square (double x);
// return x*x;
// void print_square(double x)
{ bool done=false;//loop quit variable
while(done!=true)//The main program loop.
{
cout<<" This is my FIRST STEP to a Higher programming skills ";
cout<<"please hit ENTER to continue... "<<"\n";
cout<<"\n";
cout << "1 - Addition.\n2 - Substraction.\n3 - Division.\n4 - Multiplication.\n5 - Squareroot.\n6 - Quit.\n";//This is the menu
int choice=0; //Declare the variable choice and set its value to 0
cin >> choice;//Get the user input and put it in choice
switch(choice)
{
case 1: //Addition
double x;
double y;
cout<<"This is a decimal and whole numbers sum calculator "<<"\n";
cout<<"\n";
cout<<"Please input one of the two numbers to be added, then hit ENTER: ";
cin>> x;
cout<<"\n";
cout<<"Please input the second of the two numbers to be added,then hit ENTER: ";
cin>> y;
cin.ignore();
cout<<"\n";
cout<<"\n";
cout<<"The result of adding "<< x <<" and... "<< y <<" is = to "<< ( x + y ) <<"\n";
cout<<"\n";
cout<<"\n";
cout<<"Then the product of your two numbers is "<< ( x + y ) <<"\n";
cout<<"\n";
cout<<"Please hit ENTER to decide what do you want to do next, select your number option and then press ENTER again... "<<"\n";
cin.get();
break;
case 2:
cout<<"This is a decimal and whole numbers Substraction calculator "<<"\n";
cout<<"\n";
cout<<"Please input one of the two numbers to be substracted, then hit ENTER: ";
cin>> x;
cout<<"\n";
cout<<"Please input the second of the two numbers to be substracted,then hit ENTER: ";
cin>> y;
cin.ignore();
cout<<"\n";
cout<<"\n";
cout<<"The result of substracting "<< x <<" and... "<< y <<" is = to "<< ( x - y ) <<"\n";
cout<<"\n";
cout<<"\n";
cout<<"Then the product of your two numbers is "<< ( x - y ) <<"\n";
cout<<"\n";
cout<<"Please hit ENTER to decide what do you want to do next, select your number option and then press ENTER again... "<<"\n";
cin.get();
break;
case 3:
cout<<"This is a decimal and whole numbers division calculator "<<"\n";
cout<<"\n";
cout<<"Please input one of the two numbers to be divided, then hit ENTER: ";
cin>> x;
cout<<"\n";
cout<<"Please input the second of the two numbers to be divided,then hit ENTER: ";
cin>> y;
cin.ignore();
cout<<"\n";
cout<<"\n";
cout<<"The result of dividing "<< x <<" and... "<< y <<" is = to "<< ( x / y ) <<"\n";
cout<<"\n";
cout<<"\n";
cout<<"Then the product of your two numbers is "<< ( x / y ) <<"\n";
cout<<"\n";
cout<<"Please hit ENTER to decide what do you want to do next, select your number option and then press ENTER again... "<<"\n";
cin.get();
break;
case 4:
double mult ( double x, double y );
cout<<"This is a decimal and whole numbers multiplier calculator "<<"\n";
cout<<"\n";
cout<<"Please input one of the two numbers to be multiplied, then hit ENTER: ";
cin>> x;
cout<<"\n";
cout<<"Please input the second of the two numbers to be multiplied,then hit ENTER: ";
cin>> y;
cin.ignore();
cout<<"\n";
cout<<"\n";
cout<<"The result of multiplying "<< x <<" and... "<< y <<" is = to "<< mult ( x, y ) <<"\n";
cout<<"\n";
cout<<"\n";
cout<<"Then the product of your two numbers is "<< mult ( x, y ) <<"\n";
cout<<"\n";
cout<<"Please hit ENTER to decide what do you want to do next, select your number option and then press ENTER again... "<<"\n";
cin.get();
break;
case 5:
{
return x*x;
}
void print_square(double x);
double square (double x);
cout<< "the square of " << x <<" is " << square(x) << " \n ";
//int input;
//int main()
// double x;
cin.ignore();
// tryAgain:
cout<<"This is a Square root calculator "<<"\n";
cout<<"\n";
cout<<"Please input a number to be root squared then hit ENTER: ";
cin>> x;
cout<<"\n";
cin.ignore();
cout<<"\n";
cout<<"\n";
cout<<"The result of root square "<< x <<" is = to "<< square (x) <<"\n";
cout<<"\n";
cout<<"\n";
//cout<<"Then the product of your two numbers is "<< mult ( x, y ) <<"\n";
cout<<"\n";
cout<<"Please hit ENTER to decide what do you want to do next, select your number option and then press ENTER again... "<<"\n";
cin.get();
break;
case 6:
cout<<"Thank you, see you soon!\n";
break;
default: // Note the colon, not a semicolon
cout<<"Error, bad input, quitting\n";
break;
} //******here is line 174******
}
// cin.get();
|