- Joined
- Aug 4, 2010
- Messages
- 572
- Reaction score
- 177
Making a calculator using C++. I'm going to add more features such as addition, subtraction, and division. So far I just added 1 component in this calculator.
Since this is not strictly a tutorial but a reference, I will just use a freeway of explaining whats going on.
UPDATE: 06/04/11 08:09 // This is the last Update for this.
Features:
You can take the source code and make this calculator more advanced if you feel like.
-I removed old sources.
Since this is not strictly a tutorial but a reference, I will just use a freeway of explaining whats going on.
UPDATE: 06/04/11 08:09 // This is the last Update for this.
Features:
- Multiplication
- Division
- Addition
- Subtraction
- Multiplication Chart ( Allows user to view the entire chart with input
- Division Chart ( Allows user to view the entire chart with input
- Subtraction Chart ( Allows user to view the entire chart with input
- Addition Chart ( Allows user to view the entire chart with input
- Completely working Menu for selections
- Time/Date Support
Code:
#include <cstdlib>
#include <iostream>
using namespace std;
void MultiplicationChart() {
int x;
int y;
int array[13][13];
for ( x = 0; x < 13; x ++ ) {
for ( y = 0; y < 13; y ++ )
array[x][y] = x * y;
}
cout <<"Multiplication Chart: \n";
for ( x = 0; x < 13; x ++ ) {
for ( y =0; y < 13; y ++ )
cout <<"["<<x<<"]["<<y<<"]="<< array[x][y] << " ";
cout <<"\n";
system("pause");
}
}
void DivisionChart() {
int x;
int y;
int array[13][13];
for ( x = 0; x < 13; x ++ ) {
for ( y = 0; y < 13; y ++ )
array[x][y] = x / y;
}
cout <<"Division Chart: \n";
for ( x = 0; x < 13; x ++ ) {
for ( y =0; y < 13; y ++ )
cout <<"["<<x<<"]["<<y<<"]="<< array[x][y] << " ";
cout <<"\n";
system("pause");
}
}
void SubtractionChart() {
int x;
int y;
int array[13][13];
for ( x = 0; x < 13; x ++ ) {
for ( y = 0; y < 13; y ++ )
array[x][y] = x - y;
}
cout <<"Subtraction Chart: \n";
for ( x = 0; x < 13; x ++ ) {
for ( y =0; y < 13; y ++ )
cout <<"["<<x<<"]["<<y<<"]="<< array[x][y] << " ";
cout <<"\n";
system("pause");
}
}
void AdditionChart() {
int x;
int y;
int array[13][13];
for ( x = 0; x < 13; x ++ ) {
for ( y = 0; y < 13; y ++ )
array[x][y] = x + y;
}
cout <<"Addition Chart: \n";
for ( x = 0; x < 13; x ++ ) {
for ( y =0; y < 13; y ++ )
cout <<"["<<x<<"]["<<y<<"]="<< array[x][y] << " ";
cout <<"\n";
system("pause");
}
}
int main()
{
int x;
int y;
int c;
int b;
char choice;
for (;;){
do {
cout <<"\t\t\tThe Calculator 1.0";
cout <<"\n\n\n1.Multiplication\n";
cout <<"2.Division\n";
cout <<"3.Addition\n";
cout <<"4.Subtraction\n";
cout <<"5.Time table charts";
cout <<"\n6.Quit.";
cout <<"\n\nSelection: ";
cin>>choice;
} while ( choice < '1' || choice > '6' && choice != '6');
if (choice == '6') break;
switch (choice) {
case '1' :
system("cls");
cout <<"\t\t\tThe Multiplication Section.\n\n\n";
cout << "What numbers would you like to multiply?\n";
cout <<"Number: ";
cin >> x;
cout <<"\nX\n";
cout <<"\nSecound Number: ";
cin >> y;
cin.ignore();
cout <<"\nThe Answer is: " << x * y << "\n";
system("pause");
system("cls");
break;
case '2' :
system("cls");
cout <<"\t\t\tThe Division Section.\n\n\n";
cout << "What numbers would you like to divide?\n";
cout <<"\nFirst Number: ";
cin >> c;
cout <<"\n/\n";
cout <<"\nSecound Number: ";
cin >> b;
cout <<"The Answer is: " << c / b << "\n";
cin.get();
system("pause");
system("cls");
break;
case '3' :
system("cls");
cout <<"\t\t\tThe Addition Section.\n\n\n";
cout << "What numbers would you like to add?\n";
cout <<"\nFirst Number: ";
cin >> c;
cout <<"\n+\n";
cout <<"\nSecound Number: ";
cin >> b;
cout <<"The Answer is: " << c + b << "\n";
cin.get();
system("pause");
system("cls");
break;
case '4' :
system("cls");
cout <<"\t\t\tThe Subtraction Section.\n\n\n";
cout << "What numbers would you like to subtract?\n";
cout <<"\nFirst Number: ";
cin >> c;
cout <<"\n-\n";
cout <<"\nSecound Number: ";
cin >> b;
cout <<"The Answer is: " << c - b << "\n";
cin.get();
system("pause");
system("cls");
break;
case '5' :
int chart;
cout <<"What chart would you like to display? \n";
cout <<"1.Multiplication\n";
cout <<"2.Division(Not Working)\n";
cout <<"3.Subtraction\n";
cout <<"4.Addition\n";
cout <<"Chart: ";
cin >> chart;
if ( chart == 1 ) {
MultiplicationChart();
}
else if ( chart == 2 ) {
DivisionChart();
}
else if ( chart == 3 ) {
SubtractionChart();
}
else if ( chart == 4 ) {
AdditionChart();
}
break;
}
}
return 0;
}
You can take the source code and make this calculator more advanced if you feel like.
-I removed old sources.
Last edited: