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
|
/* Math Solver with switch cases */
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
while (true) {//This repeats the program. You close window manually by clicking "x".
system("CLS");
cin.clear(); // this will clear any values remain in cin from prior run
int num;
cout<<">>>>>>>>>>>>>>>>>>>Welcome to Math Solver<<<<<<<<<<<<<<<<<<<\nFor Formulas press 1.\nFor Advanced Numbers press 2.\nFor Basic Math press 3.\n";
cin>>num;
switch(num){
case 1:
cout<<"For Area press 1.\nFor Volume press 2.\nFor Circumfrence press 3.(Circles)\n";
cin>>num;
switch(num){
case 1:
cout<<"Area.\n\n";
int l, w; // this is the length, and width
cout<<"Enter The Length: ";
cin>>l;
cout<<"Enter the Width: ";
cin>>w;
cout<<"The area is ";
cout<<l * w;
cout<<"\n\n";
break;
case 2:
cout<<"Volume.\n\n";
int l1, w1, h1; // this is the length, width, and height
cout<<"Enter the Length: ";
cin>>l1;
cout<<"Enter the Width: ";
cin>>w1;
cout<<"Enter the Height: ";
cin>>h1;
cout<<"The Volume is ";
cout<<l1 * w1 * h1;
cout<<"\n\n";
break;
case 3:
cout<<"Circumfrence.\n\n"; // ((2(r))pi) or C=2 * pi * R
int c;
cout<<"Enter the radius: ";
cin>>c;
cout<<"the circumfrence is ";
cout<<2*c*3.14159;
cout<<"\n\n";
break;
}
break;
cout<<"\n\n";
case 2:
cout<<"For Square Root's press 1\nFor Powers press 2\n";
cin>>num;
switch(num) {
case 1:
cout<<"Square Roots: "; // Can not access this anymore
int n00;
cout<<"Enter the number that you want to know the Square Root of: ";
cin>>n00;
{
double param, result;
param=n00;
result=sqrt (param);
printf("The square root of (%lf) is %lf\n", param, result );
}
cout<<"\n\n";
break;
case 2:
cout<<"Powers: ";// in progress and need a lot of help in this
double n01, n02, result; // these must be double or float
n01=n02=result=0; // intializing
std::cout<<"Please enter the Base: ";
std::cin>>n01;
std::cout<<"Please enter Exponntial: ";
std::cin>>n02;
result=pow(n01, n02);
std::cout<<n01<<"^"<<n02<<" = "<<result<<'\n';
break;
}
break;
case 3:
cout<<"Back to the basics.\nFor Adding Press 1.\nFor Subtracting Press 2.\nFor Multiplication Press 3.\nFor Division Press 4.\n";
cin>>num;
switch(num) {
case 1:
int n03, n04;
cout<<"Adding\nEnter your First number: ";
cin>>n03;
cout<<"Enter your second number:";
cin>>n04;
cout<<n03<<" + "<<n04<<" = "<<n03+n04<<"\n";
break;
case 2:
int n05, n06;
cout<<"Subtracting\nEnter your First Number: ";
cin>>n05;
cout<<"Enter your Second Number: ";
cin>>n06;
cout<<n05<<" - "<<n06<<" = "<<n05 - n06<<"\n";
break;
case 3:
int n07, n08;
cout<<"Multiplying\nEnter your First Number: ";
cin>>n07;
cout<<"Enter your Second Number: ";
cin>>n08;
cout<<n07<<" X "<<n08<<" = "<<n07*n08<<'\n';
break;
case 4:
int n09, n10;
cout<<"Dividing\nEnter your First Number: ";
cin>>n09;
cout<<"Enter your Second Number: ";
cin>>n10;
cout<<n09<<" / "<<n10<<" = "<<n09/n10<<"\n";
break;
break;
}
}
system("PAUSE");
}//this ends while loop
return 0;
}// this ends your main function.
|