Well im trying to make a math solver program that will solve almost any math question its not currently complete but i want to make it so you dont have to always close and reopen the program.
This is my full code so far
(EDIT)
I Have Replaced the default code with my edited one so it now has the infinate loop and the sqrt code plugged in
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
|
/* 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<<<<<<<<<<<<<<<<<<<\n";
cout << "For Shapes type press 1.\n";
cout << "For Square Roots press 2.\n";
cin >> num;
switch(num) {
case 1:
cout << "For Area press 1.\n";
cout << "For Volume press 2.\n";
cin >> num;
switch(num) {
case 1:
cout << "Area.\n";
int lg; // this declares a varable
int wg; // this declares another varable
cout << "This is a program to find the area of a Rectangle and Square.\n";
cout << "Enter The Length: ";
cin >> lg; // input the length
cout << "Enter the Width: ";
cin >> wg; // input the width
cout << "The area is ";
cout << lg * wg; // compute area
break;
case 2:
cout << "Volume.\n";
int l;
int w;
int h;
cout << "Enter the Lenght: ";
cin >> l;
cout << "Enter the Width: ";
cin >> w;
cout << "Enter the Hight: ";
cin >> h;
cout << "The Volume is ";
cout << l * w * h;
break;
}
cout << "\n\n";
case 2:
cout << "Square Roots: "; // Currently in progress
{
double param, result;
param = 1024.0;
result = sqrt (param);
printf ("sqrt(%lf) = %lf\n", param, result );
}
cout << "\n\n";
break;
}
system ("PAUSE");
}//this ends while loop
return 0;
}// this ends your main function.
|
What can i input to change the code to return to the top
also i would like to input a code that if you type Q or another command anywhere in the program it will ask if you want to quit also how can i change my code to be asking to ex: area is a, volume is v, etc.
also if there are any other codes that would be recommened they would be greatly accepted thanks
<EDIT>
This code works completely and is not a school project its just a project that i'm working on by my self if it looks like a school project i'm sorry and if there is a related topic please send the url (link) to the solution
i'm not asking for someone to fix my program but a little assistance
also if you want you can use my code but if you do get it complete please give me a little credit for starting the code and also send me a message if you got any questions.
also i know that i don't have the square root part of the code plugged into this program im currently stuck on that part