Update main.cpp

main
DavidDGTNTSchool 2021-06-16 16:21:47 -04:00 committed by GitHub
parent 8d8c049a5d
commit 3e8c817b0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 83 additions and 49 deletions

132
main.cpp
View File

@ -1,62 +1,96 @@
#include <iostream> #include <iostream>
#include <string>
#include <math.h>
using namespace std; using namespace std;
int main() string version = "2.0";
{ bool inDev = true;
int oper;
double num1; int main() {
double num2; cout << "David Calc" << endl;
cout << "DDDD GGG TTTTT N N TTTTT" << endl; cout << "Version " << version << endl;
cout << "D D G T NN N T " << endl; if (inDev) {
cout << "D D G G T N N N T " << endl; cout << "Development build" << 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;
} }
if(oper == 2) { cout << "1 - +" << endl;
cout << "What is your minuend? "; 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; cin >> num1;
cout << endl; cout << "Addend 2:" << endl;
cout << "What is your subtrahend? "; float num2;
cin >> num2; cin >> num2;
cout << endl; float result = num1 + num2;
cout << num1 << " - " << num2 << " = " << num1-num2 << endl; cout << "Sum: " << result << endl;
} else if (op == "2") {
cout << "-" << endl;
cout << "Minuend:" << endl;
float num1;
cin >> num1;
cout << "Subtrahend:" << endl;
float num2;
cin >> num2;
float result = num1 - num2;
cout << "Difference: " << result << endl;
} else if (op == "3") {
cout << "*" << endl;
cout << "Factor 1:" << endl;
float num1;
cin >> num1;
cout << "Factor 2:" << endl;
float num2;
cin >> num2;
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;
} }
if(oper == 3) { } else if (op == "5") {
cout << "What is your first number? "; 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; cin >> num1;
cout << endl; cout << "Divisor:" << endl;
cout << "What is your second number? "; int num2;
cin >> num2; cin >> num2;
cout << endl; if (num2 == 0) {
cout << num1 << " x " << num2 << " = " << num1*num2 << endl; cout << "Division by zero error!";
} else {
int result = num1 / num2;
int mod = num1 % num2;
cout << "Quotient: " << result << " R" << mod << endl;
} }
if(oper == 4) { } else {
cout << "What is your dividend? "; cout << "Invalid operation." << endl;
cin >> num1; main();
cout << endl;
cout << "What is your divisor? ";
cin >> num2;
cout << endl;
cout << num1 << " / " << num2 << " = " << num1/num2 << endl;
} }
return 0; return 0;
} }