Wyo (09-05-2010)
I decided to make a math calculator because the math courses at my college had some geometry (Yes, this calculator also has geometry in it) in them.
Of course, this saves so much time.
I'm planning on adding formulas for more 3-d shapes soon.
I'm not sure if this will work for you windows users since I programmed this with a mac.
Souce code:
/* C++ Calculator made
by Hyperion */
#include <iostream>
using namespace std;
int main ()
{
cout << "This calculator was programmed by Hyperion with c++.";
cout << "\nPlease do not redistribute the program without the authorized";
cout << "\nconsent of the programmer!";
int a, j;
double b, c, d, e, f, g, h, i, k, l, m, n, o, p, q;
cout << "\nWelcome!!!\n";
do
{
cout << "\nWould you like basic arithmetic calculator or geometry calculator?\n";
cout << "\n(Basic Arithmetic = 1 | Geometry = 5):";
cin >> a;
if (a == 1)
{
cout << "\nWould you like to add, subtract, multiply, or divide?";
cout << "\n(Add = 1 | Subtract = 2 | Multiply = 3 | Divide = 4):";
cin >> a;
if (a == 1)
{
cout << "Addition it is. Please enter your first number:";
cin >> b;
cout << "\nPlease enter a number to add with:";
cin >> c;
cout << "\nYour number is\n";
cout << b + c;
}
if (a == 2)
{
cout << "Subtraction it is. Please enter a number:";
cin >> d;
cout << "Please enter a number to subtract with:";
cin >> e;
cout << "\nYour number is\n";
cout << d - e;
}
if (a == 3)
{
cout << "Multiply it is. Please enter a number:";
cin >> f;
cout << "\nPlease enter a number to multiply with:\n";
cin >> g;
cout << "Your number is\n";
cout << f * g;
}
if (a == 4)
{
cout << "Divide it is. Please enter a number:";
cin >>h;
cout << "Please enter a number to divide with:";
cin >> i;
cout << "\nYour number is\n";
cout << h / i;
}
if (a > 4)
{
cout << "Program error!!!";
}
if (a < 1)
{
cout << "Program error!!!";
}
cout << "\nThanks for using the C++ Calculator!\n";
}
if (a == 5)
{
double r, s, t, u;
cout << "\nWhat shape are you trying to find the area/volume of?\n";
cout << "(Square = 1 | Triangle = 2 | Circle = 3 | Rectangle = 4 | Sphere = 5):";
cin >> j;
if (j == 1)
{
cout << "\nPlease enter the side length of the square:";
cin >> k;
cout << "\nThe area of the sqare is\n";
cout << k * k;
}
if (j == 2)
{
cout << "\nPlease enter the base of the triangle:";
cin >> l;
cout << "\nPlease enter the height of the triangle:";
cin >> m;
n = l * m * .5;
cout << "\nThe area of the triangle is\n";
cout << n;
}
if (j == 3)
{
cout << "\nPlease enter the radius of the circle:";
cin >> o;
p = o * o;
q = p * 3.14;
cout << "\nThe area of the circle is\n";
cout << q;
}
if (j == 4)
{
cout << "\nPlease enter the the width of the rectangle:";
cin >> r;
cout << "\nPlease enter the length of the rectange:";
cin >> s;
cout << "\nThe area if the rectangle is\n";
cout << r * s;
}
if (j == 5)
{
cout << "\nPlease enter the radius of the sphere:";
cin >> t;
u = 1.33333333 * 3.14 * t * t * t;
cout << "\nThe voluma of the sphere is\n";
cout << u;
}
cout << "\nThanks for using the C++ Calculator!";
}
} while (a != 0);
return 0;
}
Last edited by Hyperion; 09-05-2010 at 12:31 AM.
Wyo (09-05-2010)
Couldn't you have compiled it into a .exe or a Windows Compatible Format!
Minion Statistics
Ex-Console Minion: 13/01/2011 ~ 19/04/2011
Console Re-Minion: 14/06/2012 ~ 27/02/2013
AVA Minion: 22/06/2012 ~ 12/11/2012
Battlefield Minion: 04/02/2013 ~ 27/02/2013
Computer SpecificationsCase: NZXT Phantom 820
PSU: Corsair HX-850W V2
Mobo: ASUS Z87-Deluxe
CPU: Intel Core i7-4770K
CPU Cooling: Swiftech H220 All-In-One Liquid Cooler (Cooled by 2x Noctua NF-F12 PWM 120mm Fans)
RAM: Corsair Platinum Dominators CMD16GX3M2A2400C10 (2x8GB DDR3 2400Mhz XMP)
GFX: ASUS GeForce GTX 770 DirectCU II OC 2GB
Monitor: LG 29EB93 29" Ultrawide LED IPS Panel (2560x1080)(29:1 Ratio)
Mouse: Razer Deathadder 2012
Keyboard: Ducky DK 9008G2 Cherry MX-Brown Mechanical Keyboard
I'm Alen on Steam. RIP Skype Friday nights.
I'm Navi's lover ♥
Messenger: Toxin about Dave | Paladin on Skyrim's AI | Dakota on JB | Royku leeching | Sjoerd's penis | Blitz's derpiness | Jason on Blitz
Dave84311: God I've always wanted to eat crayons, with their vibrant colors. Only if they had taste.
Mr. Lonely: @Alen I like making you wet, it makes me hard.
The C switch Statement (C)
and indent your code so it is easier to read.
try to use as less variables as possible...
there also is a C++ section on mpgh
Here didnt work in Windows Vista Ultimate but I got a Mac too so i will try there
[MPGH]Justin (09-05-2010)
Minion Statistics
Ex-Console Minion: 13/01/2011 ~ 19/04/2011
Console Re-Minion: 14/06/2012 ~ 27/02/2013
AVA Minion: 22/06/2012 ~ 12/11/2012
Battlefield Minion: 04/02/2013 ~ 27/02/2013
Computer SpecificationsCase: NZXT Phantom 820
PSU: Corsair HX-850W V2
Mobo: ASUS Z87-Deluxe
CPU: Intel Core i7-4770K
CPU Cooling: Swiftech H220 All-In-One Liquid Cooler (Cooled by 2x Noctua NF-F12 PWM 120mm Fans)
RAM: Corsair Platinum Dominators CMD16GX3M2A2400C10 (2x8GB DDR3 2400Mhz XMP)
GFX: ASUS GeForce GTX 770 DirectCU II OC 2GB
Monitor: LG 29EB93 29" Ultrawide LED IPS Panel (2560x1080)(29:1 Ratio)
Mouse: Razer Deathadder 2012
Keyboard: Ducky DK 9008G2 Cherry MX-Brown Mechanical Keyboard
i actually expected a troll hyperion
Way too high for me.
Minecraft Wiki Manager since: 2012.12.16.
Games Wiki Manager since: 2012.12.16Minecraft Section Minion: 2013.05.04.-2014.05.04
League of Legends Section Minion: 2013.05.04.-2014.05.04
Need for Speed World Minion: 2013.07.23.-2014.05.04
Steam Games Section Minion: 2013.08.05.-2014.05.04
Warrock Section Minion: 2013.10.09.-2014.05.04
If you would like to become a Minecraft Wiki Editor, apply here!
If you would like to become a Games Wiki Editor, PM me!
Gifts:
Gyongytyuk,Gyongytyuk,Zaps
well good job i guess
[/URL]
You should be able to wrap code tags around it...
There's my first calculator. /Code:#include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nNumberofArgs, char* pszargs[]) { cout << "Welcome to Ryan's four function calculator." << endl; cout << "Functions are defined as follows: 1 - Add. 2 - Sub. 3 - Mult."; cout << " and 4 - Div." << endl; cout << "Please enter the function you desire by number." << endl; int choice; cout << "Enter 1, 2, 3, or 4:"; cin >> choice; switch(choice) { case 1: //addition case //enter first number double num1; cout << "Enter first number to be added:"; cin >> num1; //enter second number double num2; cout << "Enter second number to be added:"; cin >> num2; //calculate answer double answer1; answer1 = num1 + num2; //declare answer cout << "Answer is:"; cout << answer1 << endl; break; case 2: //subtraction case //enter first number double num3; cout << "Enter number to be subtracted from:"; cin >> num3; //enter second number double num4; cout << "Enter second number to be subtracted from first:"; cin >> num4; //calculate answer double answer2; answer2 = num3 - num4; //declare answer cout << "Answer is:"; cout << answer2 << endl; break; case 3: //multiply case //enter first number double num5; cout << "Enter first number to be multiplied:"; cin >> num5; //enter second number double num6; cout << "Enter second number to be multiplied:"; cin >> num6; //calculate answer double answer3; answer3 = num5 * num6; //declare answer cout << "Answer is:"; cout << answer3 << endl; break; case 4: //division case //enter first number double num7; cout << "Enter number to be divided:"; cin >> num7; //enter second number double num8; cout << "Enter second number to divide by:"; cin >> num8; //calculate answer double answer4; answer4 = num7 / num8; //declare answer cout << "Answer is:"; cout << answer4 << endl; break; default: cout << "None of the four operations were chosen." << endl; } cout << "Thank you for using my quad operation calculator." << endl; system("PAUSE"); return 0; }
I used a switch method in this one.
It's not hard at all, you just state cases.
It saves a lot of time as opposed to writing if statement after if statement.
Last edited by Ryan; 09-05-2010 at 01:51 AM.