Homework 6

/2010_F18/wk6/hw6.cpp

The purpose of this assignment is to declare, call, and define function definitions for a menu based program that will mulitpy, divide, power of, validate, and find the minimum of three integers.

  Welcome to the CS2010 Homework 6 Menu
  =====================================
  1.  Multiply two integers
  2.  Divide two integers
  3.  Power of base and exponent
  4.  Check if a number is within the range 10-20
  5.  Find the minimum of a list of 3 numbers

  0.  Exit
  =====================================
  Enter selection:

From within each case statement, there will be a void function that gets the input from the user and stores the input into the referenced variables, and a second function that takes the input as parameters, does the task and will return the result. Use #defined constants for the switch statment's cases.

do{
 printMenu();
 cin >> choice;
 switch(choice) {
  case MULTIPLY:
    get_input(a, b);
    cout << "The result is " << multiply(a, b) << endl;
    break;
  case DIVIDE:
    get_input(a, b);
    cout << "The result is " << division(a, b) << endl;
    break;
  case POWER:
    get_input(a,b);
    cout << "The result is " << power(a, b) << endl;
    break;
  case IN_RANGE:
    get_input(a);
    if(do_check(a))
      cout << a << "is within range" << endl;
    else
      cout << a << "is not within range" << endl;
    break;
  case FIND_MIN:
    get_input(a,b,c);
    cout << "The min is" << find_min(a,b,c)<< endl;
    break;
  case EXIT:
    break;
  default:
    cout << "Invalid Option" << endl;
    break;
 }
}while(choice!=EXIT);
    
You should have at least the following 9 functions in your final code. More functions are fine if you wish to break each menu item task into subtasks.