arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Math Problem Solver
#1
Hello Friends,
I have scripted a calculator for some math problems.I have added funcation to check prime numbers.This program will also show you about vowel and consonant(non vowel) if you put alphabet.I have created this program in Visual C++ .


#include<iostream>
using namespace std;
void main();

void MainMenu()
{
cout<<" 1.Addition"<<endl;
cout<<" 2.Subtraction"<<endl;
cout<<" 3.Multiplication"<<endl;
cout<<" 4.Division"<<endl;
cout<<" 5.Remainder"<<endl;
cout<<" 6.Factorial"<<endl;
cout<<" 7.Even or Odd"<<endl;
cout<<" 8.Prime or Not"<<endl;
cout<<" 9.Vowel or Consonant"<<endl;
cout<<" 10.Exit"<<endl<<endl;
cout<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~"<<endl;
}

void Add()
{
system("color 4a");
cout<<"~~~~~~~~~~~~~~~You Choose Addition~~~~~~~~~~~~~~"<<endl<<endl;
double a,b;
cout<<"Enter the Value of A = ";
cin>>a;
cout<<"Enter the Value of B = ";
cin>>b;
cout<<endl;
cout<<a<<" + "<<b<<" = "<<a+b<<endl<<endl;
cout<<"1.For Again Addtion"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Add();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}

void Sub()
{
system("color 1d");
cout<<"~~~~~~~~~~~~~~~You Choose Subtraction~~~~~~~~~~~~~~"<<endl<<endl;
double a,b;
cout<<"Enter the Value of A = ";
cin>>a;
cout<<"Enter the Value of B = ";
cin>>b;
cout<<endl;
cout<<a<<" - "<<b<<" = "<<a-b<<endl<<endl;
cout<<"1.For Again Subtraction"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Sub();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}

void Mul()
{
system("color 5e");
cout<<"~~~~~~~~~~~~~~~You Choose Multiplication~~~~~~~~~~~~~~"<<endl<<endl;
double a,b;
cout<<"Enter the Value of A = ";
cin>>a;
cout<<"Enter the Value of B = ";
cin>>b;
cout<<endl;
cout<<a<<" * "<<b<<" = "<<a*b<<endl<<endl;
cout<<"1.For Again Multiplication"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Mul();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}

void Div()
{
system("color 2f");
cout<<"~~~~~~~~~~~~~~~You Choose Division~~~~~~~~~~~~~~"<<endl<<endl;
double a,b;
cout<<"Enter the Value of A = ";
cin>>a;
cout<<"Enter the Value of B = ";
cin>>b;
cout<<endl;
cout<<a<<" / "<<b<<" = "<<a/b<<endl<<endl;
cout<<"1.For Again Division"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Div();
break;
case 2:
main();
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}

void Rem()
{
system("color 2b");
cout<<"~~~~~~~~~~~~~~~You Choose Remainder~~~~~~~~~~~~~~"<<endl<<endl;
int a,b;
cout<<"Enter the Value of A = ";
cin>>a;
cout<<"Enter the Value of B = ";
cin>>b;
cout<<endl;
cout<<a<<" % "<<b<<" = "<<a%b<<endl<<endl;
cout<<"1.For Again Remainder"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Rem();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}

void Fac()
{
system("color 5b");
cout<<"~~~~~~~~~~~~~~~You Choose Factorial~~~~~~~~~~~~~~"<<endl<<endl;
int a,b,c;
cout<<"Enter the Number = ";
cin>>a;
c=a;
for(b=a-1;b>0;b--)
a=b*a;
cout<<endl;
cout<<"Factorial of "<<c<<" = "<<a<<endl<<endl;
cout<<"1.For Again Factorial"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Fac();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}

}

void EvOd()
{
system("color 6a");
cout<<"~~~~~~~~~~~~~~~You Choose Even or Odd~~~~~~~~~~~~~~"<<endl<<endl;
int a;
cout<<"Enter a Number = ";
cin>>a;
cout<<endl;
if(a%2==0)
cout<<a<<" is Even "<<endl<<endl;
else
cout<<a<<" is Odd "<<endl<<endl;
cout<<"1.For Again Even or Odd"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
EvOd();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}

void Pri()
{
system("color 6a");
cout<<"~~~~~~~~~~~~~~~You Choose Prime or Not Prime~~~~~~~~~~~~~~"<<endl<<endl;
int a,b,c=0;
cout<<"Enter a Number = ";
cin>>a;
cout<<endl;
for(b=2;b<a;b++)
if(a%b==0)
c=c+1;

if(c==0)
cout<<a<<" is Prime "<<endl<<endl;
else
cout<<a<<" is Not Prime"<<endl<<endl;
cout<<"1.For Again Prime or Not Prime"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Pri();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}

void Vow()
{
system("color 6a");
cout<<"~~~~~~~~~~~~~~~You Choose Vowel or Consonant~~~~~~~~~~~~~~"<<endl<<endl;
char a;
cout<<"Enter an Alphabet = ";
cin>>a;
cout<<endl;
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
cout<<a<<" is Vowel"<<endl<<endl;
else
cout<<a<<" is Consonant"<<endl<<endl;
cout<<"1.For Again Vowel or Consonant"<<endl;
cout<<"2.Back to Main Menu"<<endl;
cout<<"3.Exit"<<endl;
int o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<"Enter Option = ";
cin>>o;
cout<<endl;
cout<<"~~~~~~~~~~~~~~~~~~"<<endl;
cout<<endl<<endl;
switch(o)
{
case 1:
Vow();
break;
case 2:
main();
break;
case 3:
exit(0);
break;
default:
cout<<"Wrong Entry"<<endl;
}
}
void main()
{
system("color 2f");
MainMenu();
int o;
cout<<"Enter the Choice = ";
cin>>o;
cout<<endl;
switch(o)
{
case 1:
Add();
break;
case 2:
Sub();
break;
case 3:
Mul();
break;
case 4:
Div();
break;
case 5:
Rem();
break;
case 6:
Fac();
break;
case 7:
EvOd();
break;
case 8:
Pri();
break;
case 9:
Vow();
break;
case 10:
exit(0);
break;
default :
cout<<"Wrong Entry Plese Enter Again"<<endl<<endl;
main();
}
system("pause");
}
#2
That's nice, but you could user non-compiled scripting languages such as Python, because simple usage stuff (such as this) doesn't really need to be compiled. Good job anyways.
#3
At line 339:
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'| |a=='E'||a=='I'||a=='O'||a=='U')
I think you did a mistake, you put an additional space.
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
[Image: img.php?userid=467]
Thank you Post4VPS and CubeData for my VPS!
#4
(01-29-2017, 06:25 AM)kek Wrote: At line 339:
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'| |a=='E'||a=='I'||a=='O'||a=='U')
I think you did a mistake, you put an additional space.
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')

hmm! thanks for correction.
I have updated the code in 1st post.
#5
That's nice, really good for those who are beginners to the coding field, keep up the good work!
Thanks to ShadowHosting and Post4VPS for my VPS 5!



person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting