joshdudeha

April 2nd, 2008, 06:47 PM

Would anyone take the time in compiling my source code :

#include <iostream>

using namespace std;

int main()

{

double number1;

double number2;

char choice;

for(;;) {

do {

cout << "Hello - welcome to the joshcalculator . . .\n";

cout << "This program calculates two numbers for you.\n";

cout << "\n";

cout << "1. Addition\n";

cout << "2. Subtraction\n";

cout << "3. Multiplication\n";

cout << "4. Division\n";

cout << "\n";

cout << "Please select a type of calculation by typing the number next to the calculation you'd like to do, press q to quit\n";

cout << "\n";

cin >> choice;

} while( choice < '1' || choice > '4' && choice != 'q');

if (choice == 'q') break;

switch(choice) {

case '1':

cout << "Addition\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is: " << number1 + number2 << "\n";

break;

case '2':

cout << "Subtraction\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is " << number1 - number2 << "\n";

break;

case '3':

cout << "Multiplication\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is " << number1 * number2 << "\n";

break;

case '4':

cout << "Division\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is " << number1 / number2 << "\n";

break;

}

}

return 0;

}

Quite proud of it, just a really simple calculator made in C++, I haven't used C++ before - and just got into it tonight.

What do you think for a 13 year old? xD

#include <iostream>

using namespace std;

int main()

{

double number1;

double number2;

char choice;

for(;;) {

do {

cout << "Hello - welcome to the joshcalculator . . .\n";

cout << "This program calculates two numbers for you.\n";

cout << "\n";

cout << "1. Addition\n";

cout << "2. Subtraction\n";

cout << "3. Multiplication\n";

cout << "4. Division\n";

cout << "\n";

cout << "Please select a type of calculation by typing the number next to the calculation you'd like to do, press q to quit\n";

cout << "\n";

cin >> choice;

} while( choice < '1' || choice > '4' && choice != 'q');

if (choice == 'q') break;

switch(choice) {

case '1':

cout << "Addition\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is: " << number1 + number2 << "\n";

break;

case '2':

cout << "Subtraction\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is " << number1 - number2 << "\n";

break;

case '3':

cout << "Multiplication\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is " << number1 * number2 << "\n";

break;

case '4':

cout << "Division\n";

cout << "Please enter a number: ";

cin >> number1;

cout << "\n";

cout << "Please enter another number: ";

cin >> number2;

cout << "\n";

cout << "The answer is " << number1 / number2 << "\n";

break;

}

}

return 0;

}

Quite proud of it, just a really simple calculator made in C++, I haven't used C++ before - and just got into it tonight.

What do you think for a 13 year old? xD