Predefined Functions

Lab Assignment

The assignment contains two parts.
  1. Scientific calculator. Study tracking changes and automatic indentation in MSVS described here. As you program your project below, demonstrate to the lab instructor applying automatic indentation to your code.

    Study these functions of the math library. Create a project titled Lab4_Calculator with a single file titled calculator.cpp. Write a program that:

    The process repeats. The program should quit if the user inputs an option (number) that is not listed. The dialog should look as follows:
    1. absolute value
    2. square root
    3. ceiling
    4. power
    Select an operation:  4
    Enter base: 2
    Enter exponent: 3
    The result is: 8
    Select an operation: 
    ...
    
  2. Guessing game. Create a project titled Lab4_Guess with a single file titled guess.cpp Program the following game. The computer selects a random number between 0 and 99 and asks the user to guess the number. If the user guesses incorrectly, the computer states whether the selected number is smaller or greater than the guess. The guessing repeats until the user guesses the number. The dialog should look as follows:
      I selected a number between 0 and 99, what is it?    30
      wrong, it is larger, what is it?   60
      wrong, it is smaller, what is it?  50
      wrong, it is larger, what is it?   55
      wrong, it is smaller, what is it?  53
      correct!
      
    For your program you need to use predefined randomization functions rand() and srand() as well as the time function time()

    Hints: Use fixed values of the seed for your initial debugging, use the output of time() as an unpredictable seed to start the guessing game once you debugged your program.

    Note that random value produced by rand() is out of the required range of 0-99. Use just the last two digits of the number. To get them, compute the remainder of the division by 100 of the number returned by rand()

    Do not put srand() inside the loop or anywhere, where it may be invoked more than once - it resets the random number generator.

Make sure your program adheres to proper programming style. Submit your project to the subversion repository. Do not forget to verify your submission on the web.