UMBC CMSC104 CSEE

Computer Science Dept logo

CMSC104

Problem Solving and Computer Programming

 

Extra Credit Project: Math Tutor

Due

The Extra Credit Project is worth 100 points and due at 11:59 pm, Wednesday, 17 May

Requirements Specification

Create a file named jdoe2pec.c, using the editor of your choice.

Write a program, using at least six function (specified below) that will help young students improve their math skills. The program will start by presenting the user with a cleared screen, and a menu that will list the choices for the user:

 

CMSC104 Tutor

  1. Display Instructions
  2. Addition Problems
  3. Subtraction Problems
  4. Multiplication Problems
  5. Division Problems
  6. Exit Program

If the user selects item 1, display a set of instructions to the user about how to use your program. You are to create those instructions, as you think will best help the user.

When the user selects items 2 through 5, the program will:

Clear the screen, and then present a set of five problems to the user, one at a time.

If the user answers the question correctly on the first try, the program must count that questions as correctly answered and give a message to the user (Something like "That is correct!! Good work!". Otherwise, the user will be told that the answer was wrong and that it was either too high or too low. The user must then try the same problem again until they get it right (but don't count as one correct answer.)

You must also show the problem number (number for the entire session), and the total number of correct answers, as well as the percentage of correct answers.

All problems will be created using the random number generator rand(), as shown in the lecture notes. The values must be in the range of 1 to 10. (For division, the answer must be an integer in the range of 1 to 10. For subtraction, the answer can not be a negative number.)

You do not have to seed the random number generator, but if you do, I suggest you use the time function (time.h) results for the seed:

srand( time( NULL ) );

If the user selects item 6, the program will be finished and terminate.

Notes

To clear the screen, use the system() function (stdlib.h) with the string argument of "clear":

system( "clear" );

 

When you generate two numbers in the DoSubtraction() function, you will have to make sure that the answer is not negative. The way to do that is with an additional variable and swap the two numbers:


int nr1;
int nr2;
int temp;

if ( nr1 < nr2 )
{
    temp = nr1;
    nr1 = nr2;
    nr2 = temp;
}


Functions

Write one function to -- REQUIRED:

  1. DisplayInstructions(): Display the instructions -- needs no arguments and returns no values.
  2. DoAddition(): Do the addition problems -- needs arguments and returns values.
  3. DoSubtraction(): Do the subtraction problems -- needs arguments and returns values.
  4. DoMultiplication(): Do the multiplication problems -- needs arguments and returns values.
  5. DoDivision(): Do the division problems -- needs arguments and returns values.
  6. DisplayMenu(): Display the menu -- needs arguments and returns no values.

 

Sample output

                                        CMSC104 Tutor

                     1.  Display Instructions

                     2.  Addition Problems

                     3.  Subtraction Problems

                     4.  Multiplication Problems

                     5.  Division Problems

                     6.  Exit Program

                                         Enter your choice:


Inside DisplayInstructions
(Your instructions go here.)
Press  to continue


1:  4 + 7 = 3
Sorry, that is not right.  Your answer is too low.
1:  4 + 7 = 99
Sorry, that is not right.  Your answer is too high.
1:  4 + 7 = 11
That's CORRECT!!!!!!!   00% correct
2:  1 + 4 = 5
That's CORRECT!!!!!!!   50% correct
3:  9 + 5 = 14
That's CORRECT!!!!!!!   67% correct
4:  10 + 4 = 14
That's CORRECT!!!!!!!   75% correct
5:  10 + 6 = 16
That's CORRECT!!!!!!!   80% correct
Press  to continue
 


6:  6 - 1 = 5
That's CORRECT!!!!!!!   83% correct
7:  3 - 1 = 5
Sorry, that is not right.  Your answer is too high.
7:  3 - 1 = 1
Sorry, that is not right.  Your answer is too low.
7:  3 - 1 = 2
That's CORRECT!!!!!!!   71% correct
8:  2 - 1 = 1
That's CORRECT!!!!!!!   75% correct
9:  10 - 1 = 9
That's CORRECT!!!!!!!   78% correct
10:  7 - 2 = 5
That's CORRECT!!!!!!!   80% correct
Press  to continue                        


11:  35 / 5 = 7
That's CORRECT!!!!!!!   82% correct
12:  14 / 7 = 4
Sorry, that is not right.  Your answer is too high.
12:  14 / 7 = 1
Sorry, that is not right.  Your answer is too low.
12:  14 / 7 = 2
That's CORRECT!!!!!!!   75% correct
13:  12 / 3 = 4
That's CORRECT!!!!!!!   77% correct
14:  28 / 4 = 7
That's CORRECT!!!!!!!   79% correct
15:  63 / 7 = 9
That's CORRECT!!!!!!!   80% correct
Press  to continue


16:  8 * 4 = 14
Sorry, that is not right.  Your answer is too low.
16:  8 * 4 = 99
Sorry, that is not right.  Your answer is too high.
16:  8 * 4 = 32
That's CORRECT!!!!!!!   75% correct
17:  5 * 9 = 45
That's CORRECT!!!!!!!   76% correct
18:  9 * 3 = 27
That's CORRECT!!!!!!!   78% correct
19:  7 * 9 = 63
That's CORRECT!!!!!!!   79% correct
20:  3 * 8 = 24
That's CORRECT!!!!!!!   80% correct
Press  to continue


Notice that after the first set, you should have a line that summaries the results thus far:
Number of problems done so far:  20       80%

                                      CMSC104 Tutor

                     1.  Display Instructions

                     2.  Addition Problems

                     3.  Subtraction Problems

                     4.  Multiplication Problems

                     5.  Division Problems

                     6.  Exit Program

                                         Enter your choice:
Notice that the UNIX prompt must be on the next line!

Turning In Your Project

Once you have everything absolutely correct, you must use Blackboard to submit the project to the TA for grading. Do not email it to the instructor because you will lose points for not following instructions!

When submitting the assignment, I only want the file jdoe2pEC.c. Please make the title and the file name the same when you submit it! If you submit a file named jdoe2pEC.c, the way we save the material delete everything but the last file with than name. Therefore, your file will be lost and we will give you a zero!!!! Use your login ID!!!

Grading

This project will be grade using the following scale:

Documentation 25 points
Correct Results25 points
Correct Style25 points
Other25 points

You will lose 5 points if you do not name the file correctly.
You will lose 5 points if you email the project instead of submitting it via Blackboard.
You will lose 5 points if the prompt is not on the next line.

Comments Required

        /*****************************************************/
        /* Program Header Block                              */
        /* Filename:       jdoe2pEC.c                        */
        /* Name:           Ima Student                       */
        /* Email:          jdoe2@umbc.edu                    */
        /* Date:           11 May 2006                       */
        /* Course/section: CMSC-104/0501                     */
        /* Description:                                      */
        /*     Analysis:                                     */
        /*         Input:                                    */
        /*         Output:                                   */
        /*         Constraints:                              */
        /*         Formulas:                                 */
        /*         Assumptions:                              */
        /*     Design:                                       */
        /*         (Your psuedocode goes here.)              */
        /*                                                   */
        /* Notes:          (As needed.)                      */
        /*****************************************************/

Function Header Comment Block (One for each function)

         /***********************************************************
         * Function name:    function_name                         *
         * Description:      (Your function psuedocode goes here)  *
         * Input Parameters: Name and data type of each parameter. *
         * Return Value:     Data type and description of what     *
         *                   the return value is.                  *
         ***********************************************************/
  


UMBC | CSEE |