From f282b86e8ed05d4c612622d07b2c925bf106f20b Mon Sep 17 00:00:00 2001 From: Solarleaf <124109321+Solarleaf@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:50:00 -0800 Subject: [PATCH] Update main.cpp Update to Display the full math operation and added a check on the input to detect NaN. Repeats prompt if any input is Nan. resolves #61 resolves #62 --- main.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 68 insertions(+), 13 deletions(-) diff --git a/main.cpp b/main.cpp index 5f6ade9..264a73a 100644 --- a/main.cpp +++ b/main.cpp @@ -1,21 +1,76 @@ #include #include +#include +#include + +/* +1. Upstream +- Main code +2. Origin +- Fork to create origin + +3. Clone/Local +- git clone SSH or URL +- CD into correct Folder +- Push to update origin + +3.1 Staging +git add files +git commit -m "Message resolves #62 resolves #32" +git push origin main + +git remove -v will show you list of remotes +git remote set-url origin SSHkey + +*/ int main() { - cout << "This is Kevin!\n"; - cout<<"Hi, please enter two whole numbers: "; - - int x,y; - - std::cin >> x >> y; - std::cout << "Addition: " << x + y << std::endl; - std::cout << "Subtraction: " << x - y << std::endl; - std::cout << "Multiplication: " <> inx; + std::cin >> iny; + int flag{0}; + + for (char test : inx) + { + int res = test; + if (res > 57) + { + ++flag; + } + } + for (char test : iny) + { + if (test < 48 || test > 57) + { + ++flag; + } + } + if (flag) + { + flag = 0; + continue; + } + x = std::stoi(inx); + y = std::stoi(iny); + break; + } + + std::cout << x << '+' << y << '=' << x + y << '\n'; + std::cout << x << '-' << y << '=' << x - y << '\n'; + std::cout << x << '*' << y << '=' << x * y << '\n'; + std::cout << x << '/' << y << '=' << x / y << " with remainder of " << x % y << '\n'; + std::cout << "Square Root of " << x << "is " << sqrt(x) << '\n'; + std::cout << "Square Root of " << y << "is " << sqrt(y) << '\n'; + std::cout << x << '^' << y << '=' << pow(x, y) << '\n'; return 0; }