Assignment 4

Back Up Next

Home
Assignment 1
Assignment 2
Assignment 3
Assignment 4
Assignment 5
Assignment 6
Assignment 7

CS 161
50 POINTS

DUE announced in class, check e-mail, check online schedule

Purpose: To become familiar with simple expressions and formatted output conditional loop statements.

Problem: Modify the program in assignment 3 such that:

You will now add three new math calculations of your choice. Such as, square root, quadratic equation, temperature conversion, etc.  make sure to comply with the rules of mathematics (do not allow div/0 sqrt(negative number), etc.) Let the user be aware of those rules showing instruction on the screen and you will also going to be able to protect div/0 and sqrt of negative numbers, using control structures.

Prompt the user to enter the correct input for the calculation about to be performed as you have done in previous assignment.
The user will have the choice to repeat the calculation or continue on to the next, and they will have to do all of them starting with the addition. (while, do while to control the repetition). 
Let the user guess the correct answer and compare it with the answer produced by the computer. If correct or incorrect, give the user a feedback such as Your answer is correct or Sorry, the answer is ???.
This time there is no need to have  the formatted table at the bottom.
Use the proper formatting for you code, indenting on the if, while statements, etc.
Use self explanatory variable names.
Comment all your variables and the other sections of your program.

A sample interaction with your program would be like:

<Always give a nice intro to your program and let the user is aware of what the programs does>

Hi, Welcome to the the Math drill program, you will be given the choice to repeat several math exercises.

Let's first practice some adding:

The limit for the numbers are .....

Enter your first number and press <Enter>:
4

Enter your first number and press <Enter>:
4

Enter your answer and press enter:
8

Great 4 + 4 is 8

or

Sorry 4 + 4 is ? (in case another number was entered)

Would you like to repeat another additon exercise?
y

(..repeat add )

or n

go on to subtraction.

The user will have to try all the mathematical operation before the program quits.

Turn in all in a large envelope:

Algorithm (typed)
Hard copy of you program
a sample output
floppy disk with your program (write on your disk which compiler was used)

 

  Any questions, please let your instructor know.

 

Back to CS 161 Homepage
This page was last modified May 01, 2001
wmorales@pcc.edu