Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculator v1
#20
(01-10-2010, 05:58 AM)Master of the Universe Wrote: Here I don't have the time to debug your code, but I have an modification to offer you ;)
Compiled and works as you wanted it to!

Code:
#include <iostream>
using namespace std;

int option = 0;
double a = 0;
double b = 0;

int showMenu()
{
    cout << ":::Calculator v1::: \n";
    
    cout << "Enter a Number: \n";
    cin >> a;
    cout << "Enter a Number: \n";
    cin >> b;
    cout << "1. Multiplication \n";
    cout << "2. Division \n";
    cout << "3. Addition \n";
    cout << "4. Subtraction \n";
    cout << "5. Enter new numbers \n";
    cout << "6. Quit \n";
    cout << "Enter your choice: ";
    cin >> option;  
    
    return option;
}

void Calc(int option, double num1, double num2) {
    a = num1;
    b = num2;
    switch (option) {
        case 1:
             cout << "The Result is: " << a*b << '\n';  
             break;
        case 2:
             cout << "The Result is: " << a/b << '\n';
             break;
        case 3:
             cout << "The Result is: " << a+b << '\n';
             break;
        case 4:
             cout << "The Result is: " << a-b << '\n';  
             break;
        case 5:
             break;
        case 6:
             cout << "Goodbye \n";
             break;
    }
}

int main()
{
    do {
        option = showMenu();
        do {
           Calc(option, a, b);
        } while(option<1 || option>6);
    } while(option!=6);
        return 0;
}
or that lol,very smart move Thumbsup
Reply


Messages In This Thread
Calculator v1 - by Brainless Control - 12-03-2009, 11:01 AM
RE: Calculator v1 - by Gaijin - 12-03-2009, 12:57 PM
RE: Calculator v1 - by Brainless Control - 12-03-2009, 02:06 PM
RE: Calculator v1 - by MrD. - 12-03-2009, 02:28 PM
RE: Calculator v1 - by Gaijin - 12-03-2009, 04:18 PM
RE: Calculator v1 - by Brainless Control - 12-04-2009, 02:14 AM
RE: Calculator v1 - by Brainless Control - 12-05-2009, 05:02 AM
RE: Calculator v1 - by MrD. - 12-05-2009, 07:48 AM
RE: Calculator v1 - by Brainless Control - 12-05-2009, 08:04 AM
RE: Calculator v1 - by MrD. - 12-05-2009, 08:16 AM
RE: Calculator v1 - by Brainless Control - 12-05-2009, 08:20 AM
RE: Calculator v1 - by M4X1MU5 - 12-12-2009, 05:24 AM
RE: Calculator v1 - by nextlive - 12-24-2009, 08:01 AM
RE: Calculator v1 - by Brainless Control - 01-09-2010, 07:23 AM
RE: Calculator v1 - by MrD. - 01-09-2010, 06:03 PM
RE: Calculator v1 - by Brainless Control - 01-10-2010, 03:37 AM
RE: Calculator v1 - by Gaijin - 01-10-2010, 03:43 AM
RE: Calculator v1 - by Brainless Control - 01-10-2010, 05:48 AM
RE: Calculator v1 - by Gaijin - 01-10-2010, 05:58 AM
RE: Calculator v1 - by Brainless Control - 01-10-2010, 06:05 AM
RE: Calculator v1 - by Brainless Control - 01-16-2010, 04:12 PM
RE: Calculator v1 - by Equinøx - 01-18-2010, 10:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Multi Purpose Calculator Reality 21 5,117 12-14-2010, 06:11 PM
Last Post: Buzz Lightyear
  my own calculator WHITE PANDA 8 2,193 07-14-2010, 03:19 PM
Last Post: Kondry
  Calculator in C Liberty 4 1,322 12-10-2009, 11:45 PM
Last Post: Sagittarius

Forum Jump:


Users browsing this thread: 16 Guest(s)