Homework 3 - Function Overloading and by-reference Parameters

Due: Wednesday, October 13, 2010 at 5:00pm

Name your files hw3_<problem>.cpp, such as hw3_1.cpp. Email all the cpp files to my account.

  1. (10 points) This purpose of this problem is to work with function overloading. You will write several versions of functions called find_min(), get_input() and print_min(). print_min() and get_input() will be void functions. find_min() will return a value. The functions are as follows: Use the following main function for this problem:
    int main()
    {
      int num1, num2, num3;
      double dnum1, dnum2;
    
      // Two integer version
      get_input(num1, num2);
      print_min(find_min(num1, num2));
    
      // Two double version
      get_input(dnum1, dnum2);
      print_min(find_min(dnum1, dnum2));
    
      // Three integer version
      get_input(num1, num2, num3);
      print_min(find_min(num1, num2, num3));
    
      return 0;
    }
    
  2. (10 points) Modify your simple menu program from Homework 2. The menu options will remain the same, but now each option will use a function calls instead of having all the option statements within the switch() statement.
      Welcome to the CS221 Homework 3 Menu
      ====================================
      1.  Multiply two integers
      2.  Divide two integers
      3.  Check if a number is within the range 10-20
      4.  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 using by-reference parameters and a second void function that takes the input as by-value parameters, does the task and prints the result to the screen. For example, the first menu item case statement would be:
      case 1:
        get_input(a, b);
        do_multiply(a, b);
        break;
    
    You should have at least the following 7 void functions in your final code. More functions are fine if you wish to break each menu item task into subtasks.