Project 3 Due: 20 Apr
Requirements Specfication
Write a program
that will help young students improve their math skills.
All source code is to be in one file
only!
The program will start by presenting the user with a cleared screen,
and a menu that will list the choices for the user:
When the user selects items 1 through 4
The program will:
Clear the screen, and then present a problem to the
user.
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 !!!!!!!\n".
Otherwise, the user will be told that the answer
was wrong and that it was either too high or too low.
All problems will be created using the random number generator
rand() (see notes below). 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.)
To use rand( ), you must use:
#include <stdlib.h>
after the include for stdio.h. These generates a number in the range of
0 to MAXINT, which is way too big for us, plus we don't want the zero,
so in your code when you need to generate a random number we need to
do somthing like this:
nr1 = rand( ) % 10 + 1;
If the user selects item 5
The program will be finished and terminate. Your program must
clear the screen before terminating.
Notes
Random Numbers
To use rand( ), you must use:
#include <stdlib.h>
#include <time.h>
after the include for stdio.h. These generates a number in the range of
0 to MAXINT, which is way too big for us, plus we don't want the zero,
so in your code when you need to generate a random number we need to
do somthing like this:
nr1 = rand( ) % 10 + 1;
You must also have a statement in the beginning of your program that
creates a different starting point each time:
srand( time( 0 ) );
Clear the Screen
To clear the screen, we will use the operating system to do that
in the form of:
system( "clear" ); /* Linux version */
or
system( "cls" ); /* Microsoft version */
Subtraction Hint
When you generate two numbers in the Subtraction procedure,
you will have to make sure that the answer is not negative.
if necessary, you will have to swap the two numbers to make
sure this does not have:
temp = nr1;
nr1 = nr2;
nr2 = temp;
Press Enter to Continue
Use scanf( ) to get character input. When the user simply hits
the Enter key, then the program will continue.
Sample output
Inside Addition
Answer Too Low
Answer Too High
Inside Subtraction
Inside Division
Suggestion: Generate the
divisor and quotient and multiple they together to get
the dividend. The answer must be a positive whole number!
Inside Multiplication Procedure
Your program must be identical to mine!
Program Header Comment Block
Use the following comment block at the beginning of your source code:
/*****************************************************/
/* Program Header Block */
/* Filename: 6789prj3.c */
/* Name: Ima Student */
/* SSAN: 6789 */
/* Date: 6 April 1998 */
/* Course/section: CMSC-104 */
/* Description: */
/* Analysis: */
/* Input: */
/* Output: */
/* Constraints: */
/* Formulas: */
/* Assumptions: */
/* Design: */
/* (Your psuedocode goes here.) */
/* */
/* Notes: (As needed.) */
/*****************************************************/