Created
May 11, 2018 16:50
-
-
Save edenizk/13695e335416df311167710ffbe7c202 to your computer and use it in GitHub Desktop.
QUADRATIC EQUATIONS CALCULATOR2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <math.h> | |
| #include <windows.h> | |
| #include <conio.h> | |
| using namespace std; | |
| /* run this program using the console pauser or add your own getch, system("pause") or input loop */ | |
| void progressbar(){ | |
| cout<<"\t\t "; | |
| /*Loading bar*/ | |
| for(int i=0; i<100/5; i++){ | |
| cout<<(char)177; | |
| } | |
| cout<<"<<\r\t\t\t"; | |
| for(int i = 0; i<=100; i++){ | |
| cout << "\r\t\t " << i << "% completed >>" ; | |
| for (int o=1;o<i/5;o++){ | |
| cout<<(char)219; | |
| } | |
| switch (i% 4) | |
| { | |
| case 0: cout<<"\r\t\t/"; break; | |
| case 1: cout<<"\r\t\t-"; break; | |
| case 2: cout<<"\r\t\t\\"; break; | |
| case 3: cout<<"\r\t\t-"; break; | |
| } | |
| Sleep(50); | |
| } | |
| cout<<endl; | |
| } | |
| int main(int argc, char** argv) { | |
| int a,b,c,i,d,answer; | |
| char again; | |
| do{ | |
| cout<<"\t ~WELCOME TO THE QUADRATIC EQUATIONS CALCULATOR~\n"; | |
| cout<<"\t ~Please Choose Which Calculation You Want To Do~\n\t 1-EXPONENTATION\n\t 2-nth-Root\n\t 3-Exit\n"; | |
| cin>>i; | |
| cout<<"\t"; | |
| //tester | |
| if(cin.fail()||i>3||i<1){ | |
| cin.clear(); | |
| cin.ignore(10, '\n'); | |
| cout<<"\t -Please Choose 1,2 or 3 please don't write any other value"; | |
| cout<<"\n\t -Please write it again"; | |
| cin>>i; | |
| if(cin.fail()){ | |
| cout<<"\n\n\n\t -You KICKED."; | |
| break; | |
| } | |
| } | |
| //tester | |
| if (i==1){ | |
| cout<<"\t-Enter The Base:"; | |
| cin>>a; | |
| //tester | |
| if(cin.fail()){ | |
| cin.clear(); | |
| cin.ignore(10, '\n'); | |
| cout<<"\t -Its Not a number\n\t -Please write it again\n"; | |
| cout<<"\t -Please write a positive or negative value(it must be a number):"; | |
| cin>>a; | |
| if(cin.fail()){ | |
| cout<<"\n\n\n\t -Please next time try to write a number..."; | |
| break; | |
| } | |
| } | |
| //tester | |
| cout<<"\n\t-Enter The Exponent:"; | |
| cin>>b; | |
| //tester | |
| if(cin.fail()){ | |
| cin.clear(); | |
| cin.ignore(10, '\n'); | |
| cout<<"\t -Its Not a number\n\t -Please write it again\n"; | |
| cout<<"\t -Please write a positive or negative value(it must be a number):"; | |
| cin>>b; | |
| if(cin.fail()){ | |
| cout<<"\n\n\n\t -Please next time try to write a number..."; | |
| break; | |
| } | |
| } | |
| //tester | |
| answer=pow(a,b); | |
| cout<<"\t -Please wait we are calculating your answer...\n\t\t "; | |
| progressbar(); | |
| cout<<"\n=======================> "<<a<<" ^ "<<b<<" = "<<answer<<endl<<endl; | |
| } | |
| else if(i==2){ | |
| cout<<"\t-Choose The Base To Find The Root of The Number:"; | |
| cin>>a; | |
| //tester | |
| if(cin.fail()){ | |
| cin.clear(); | |
| cin.ignore(10, '\n'); | |
| cout<<"\t -Its Not a number\n\t -Please write it again\n"; | |
| cout<<"\t -Please write a positive or negative value(it must be a number):"; | |
| cin>>b; | |
| if(cin.fail()){ | |
| cout<<"\n\n\n\t -Please next time try to write a number..."; | |
| break; | |
| } | |
| } | |
| //tester | |
| cout<<"\n\tChoose The Root:"; | |
| cin>>b; | |
| //tester | |
| if(cin.fail()){ | |
| cin.clear(); | |
| cin.ignore(10, '\n'); | |
| cout<<"\t -Its Not a number\n\t -Please write it again\n"; | |
| cout<<"\t -Please write a positive or negative value(it must be a number):"; | |
| cin>>b; | |
| if(cin.fail()){ | |
| cout<<"\n\n\n\t -Please next time try to write a number..."; | |
| break; | |
| } | |
| } | |
| //tester | |
| cout<<"\t -Please wait we are calculating your answer...\n\t\t "; | |
| progressbar(); | |
| answer=pow(a,float(1)/b); | |
| cout<<"\n=======================> "<<b<<" root "<<a<<" = "<<answer<<endl; | |
| } | |
| else if(i==3){ | |
| cout<<"Good BYE"; | |
| break; | |
| } | |
| cout<<"\n\t\t ~Do you wanna continue?[Y/N]~"; | |
| cin>>again; | |
| cout<<endl; | |
| }while(again=='y'||again=='Y'); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment