CS 210 - Fundamentals of Programming I

Spring 2006 - In-class exercise for 2/21/06

10 points

Names:

This exercise should be completed in pairs. The purpose of this exercise is to work with the case selection construct. Here is a problem statement, analysis, and design for today's in-class exercise.

Problem Statement

Write a simulator for a simple calculator. It should repeatedly perform a computation until the user wants to quit.

Main Program

Function PrintMenu


1. (4 points) Create a new project, then download the program inclass12.cpp from the course webpage and add it to your project. Build and run this program. Answer the following questions:

a.
What is the boolean expression in this program?







b.
What is the selection expression in the switch statement?







c.
Why does each case in the switch statement end with a break statement?







d.
When does the default case of the switch statement execute?








2. (6 points) Users of the calculator would like to be able to multiply and divide. Modify your program in the following way:

Save your program, then rebuild and run it. Test it until you are satisfied that it works.


When you have completed this exercise, print out your program file and turn it in with one copy of this exercise sheet with your answers to the questions.


Converted using latex2html on Tue Feb 21 00:42:06 CST 2006