Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Nova's C++ Calculator v1.1
- /*
- Updates and other information
- [NEW]**
- - Tried using switches for math, might just do separate "if functions" if problem persists.
- [BUGS]**
- - Only multiplication works at the moment.
- - Line 45
- */
- #include <iostream>
- #include <string>
- int main()
- {
- double digit1;
- double digit2;
- int process;
- double answer;
- //information gathering process
- std::cout << "Simple Calculator by Nova\n";
- std::cout << "Please enter your first number: ";
- std::cin >> digit1; //grabbing digit1 from user
- std::cout << "\n";
- std::cout << "Please enter your second number: ";
- std::cin >> digit2; //grabbing second digit
- std::cout << "\n";
- //menu
- std::cout << "--------------------------------\n";
- std::cout << "1 - Multiply\n";
- std::cout << "2 - Divide\n";
- std::cout << "3 - Add\n";
- std::cout << "4 - Subtract\n";
- std::cout << "--------------------------------";
- std::cout << "\n";
- std::cout << "Please select a process using a single digit: ";
- std::cin >> process;
- std::cout << "\n";
- if (process >= 5 || process < 1)
- {
- //Invalid Value Error [BUG 1 - LINE 45]
- std::cout << "[Error: Invalid Selection]\n";
- std::cout << "\n";
- std::cout << "Please select a process using a single digit: ";
- std::cout << "[WARNING] If you select a number that isn't on the list, the program will exit. (Currently working on a fix.";
- std::cin >> process;
- }
- if (process = 1) {
- answer = (digit1 * digit2);
- std::cout << "Answer: " << answer << "\n";
- std::cout << "Run the program again to restart the process.";
- digit1++;
- digit2++;
- } switch (process = 2) {
- answer = (digit1 / digit2);
- std::cout << "Answer: " << answer << "\n";
- std::cout << "Run the program again to restart the process.";
- digit1++;
- digit2++;
- } switch (process = 3) {
- if (process = 3){
- answer = (digit1 + digit2);
- std::cout << "Answer: " << answer << "\n";
- std::cout << "Run the program again to restart the process.";
- digit1++;
- digit2++;
- } switch (process = 4) {
- answer = (digit1 - digit2);
- std::cout << "Answer: " << answer << "\n";
- std::cout << "Run the program again to restart the process.";
- digit1++;
- digit2++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement