Not really sure if this is the place to put this or if anyone here knows c++ but..
I've been trying to learn it recently in hopes of becoming fluent one day as my first computer language.
Here's an unoriginal calculator I made.
PHP Code:
// By Mustafa
#include <iostream>
using namespace std;
float addition (float number1,float number2)
{
return number1 + number2;
}
float subtraction (float number1,float number2)
{
return number1 - number2;
}
int main(){
float number1, number2;
int choice;
cout << " Choice your operation. Addition for 1 and Subtraction for 2.";
cout << " Choice: ";
cin >> choice;
if (choice==1) {
// Addition
cout << "\n Add the first number of your choice ";
cin >> number1;
cout << "\n Add the second number of your choice ";
cin >> number2;
cout << "\n The answer to the addtion problem is " << number1 + number2;
}
else {
} if (choice==2)
{
// Subtraction
cout << "\n Add the first number of your choice ";
cin >> number1;
cout << "\n Add the second number of your choice ";
cin >> number2;
cout << "\n The answer to the subtraction problem is " << number1 - number2;
}
system ("Pause");
}
}
|
Great learning experience.
We did this assignment in my first year Computer Programming class in HighSchool. Next, we edited the calculator code to work with strings (using delimiters in Java, substrs in C++).
I'd give you the reference assignment, and code (if needed) but unfortunately, everything is on my class desktops and I won't have access to them or the syllabus until tomorrow.
Glad you're learning, we need more programmers in the world.