mirror of https://github.com/daviddgtnt/calc
Update main.cpp
parent
8d8c049a5d
commit
3e8c817b0c
132
main.cpp
132
main.cpp
|
@ -1,62 +1,96 @@
|
|||
#include <iostream>
|
||||
#include <string>
|
||||
#include <math.h>
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int oper;
|
||||
double num1;
|
||||
double num2;
|
||||
cout << "DDDD GGG TTTTT N N TTTTT" << endl;
|
||||
cout << "D D G T NN N T " << endl;
|
||||
cout << "D D G G T N N N T " << endl;
|
||||
cout << "D D G G T N NN T " << endl;
|
||||
cout << "DDDD GGG T N N T " << endl;
|
||||
cout << endl;
|
||||
cout << "DGTNT Calc 1.0" << endl;
|
||||
cout << endl;
|
||||
cout << "Options:" << endl;
|
||||
cout << "1: Addition" << endl;
|
||||
cout << "2: Subtraction" << endl;
|
||||
cout << "3: Multiplication" << endl;
|
||||
cout << "4: Division" << endl;
|
||||
cout << endl;
|
||||
cout << "Enter your operation's number: ";
|
||||
cin >> oper;
|
||||
if(oper == 1) {
|
||||
cout << "What is your first number? ";
|
||||
cin >> num1;
|
||||
cout << endl;
|
||||
cout << "What is your second number? ";
|
||||
cin >> num2;
|
||||
cout << endl;
|
||||
cout << num1 << " + " << num2 << " = " << num1+num2 << endl;
|
||||
string version = "2.0";
|
||||
bool inDev = true;
|
||||
|
||||
int main() {
|
||||
cout << "David Calc" << endl;
|
||||
cout << "Version " << version << endl;
|
||||
if (inDev) {
|
||||
cout << "Development build" << endl;
|
||||
}
|
||||
if(oper == 2) {
|
||||
cout << "What is your minuend? ";
|
||||
cout << "1 - +" << endl;
|
||||
cout << "2 - -" << endl;
|
||||
cout << "3 - *" << endl;
|
||||
cout << "4 - /" << endl;
|
||||
cout << "5 - Square Root" << endl;
|
||||
cout << "6 - /R" << endl;
|
||||
cout << "Choose an operation:" << endl;
|
||||
string op;
|
||||
cin >> op;
|
||||
if (op == "1") {
|
||||
cout << "+" << endl;
|
||||
cout << "Addend 1:" << endl;
|
||||
float num1;
|
||||
cin >> num1;
|
||||
cout << endl;
|
||||
cout << "What is your subtrahend? ";
|
||||
cout << "Addend 2:" << endl;
|
||||
float num2;
|
||||
cin >> num2;
|
||||
cout << endl;
|
||||
cout << num1 << " - " << num2 << " = " << num1-num2 << endl;
|
||||
}
|
||||
if(oper == 3) {
|
||||
cout << "What is your first number? ";
|
||||
float result = num1 + num2;
|
||||
cout << "Sum: " << result << endl;
|
||||
} else if (op == "2") {
|
||||
cout << "-" << endl;
|
||||
cout << "Minuend:" << endl;
|
||||
float num1;
|
||||
cin >> num1;
|
||||
cout << endl;
|
||||
cout << "What is your second number? ";
|
||||
cout << "Subtrahend:" << endl;
|
||||
float num2;
|
||||
cin >> num2;
|
||||
cout << endl;
|
||||
cout << num1 << " x " << num2 << " = " << num1*num2 << endl;
|
||||
}
|
||||
if(oper == 4) {
|
||||
cout << "What is your dividend? ";
|
||||
float result = num1 - num2;
|
||||
cout << "Difference: " << result << endl;
|
||||
} else if (op == "3") {
|
||||
cout << "*" << endl;
|
||||
cout << "Factor 1:" << endl;
|
||||
float num1;
|
||||
cin >> num1;
|
||||
cout << endl;
|
||||
cout << "What is your divisor? ";
|
||||
cout << "Factor 2:" << endl;
|
||||
float num2;
|
||||
cin >> num2;
|
||||
cout << endl;
|
||||
cout << num1 << " / " << num2 << " = " << num1/num2 << endl;
|
||||
float result = num1 + num2;
|
||||
cout << "Product: " << result << endl;
|
||||
} else if (op == "4") {
|
||||
cout << "/" << endl;
|
||||
cout << "Dividend:" << endl;
|
||||
float num1;
|
||||
cin >> num1;
|
||||
cout << "Divisor:" << endl;
|
||||
float num2;
|
||||
cin >> num2;
|
||||
if (num2 == 0) {
|
||||
cout << "Division by zero error!";
|
||||
} else {
|
||||
float result = num1 / num2;
|
||||
cout << "Quotient: " << result << endl;
|
||||
}
|
||||
} else if (op == "5") {
|
||||
cout << "Square Root" << endl;
|
||||
cout << "Value:" << endl;
|
||||
float num;
|
||||
cin >> num;
|
||||
float result = sqrt(num);
|
||||
cout << "Square root: " << result << endl;
|
||||
} else if (op == "6") {
|
||||
cout << "/R" << endl;
|
||||
cout << "Note: Ony integers (full numbers) are accepted." << endl;
|
||||
cout << "Dividend:" << endl;
|
||||
int num1;
|
||||
cin >> num1;
|
||||
cout << "Divisor:" << endl;
|
||||
int num2;
|
||||
cin >> num2;
|
||||
if (num2 == 0) {
|
||||
cout << "Division by zero error!";
|
||||
} else {
|
||||
int result = num1 / num2;
|
||||
int mod = num1 % num2;
|
||||
cout << "Quotient: " << result << " R" << mod << endl;
|
||||
}
|
||||
} else {
|
||||
cout << "Invalid operation." << endl;
|
||||
main();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue