ES26 - MP01 - Wilmarc
ES26 - MP01 - Wilmarc
II. Objectives
The goal of this project is for the student(s) to write a program that will serve
as a tutorial for people starting to learn basic arithmetic.
The program will present the user a series of arithmetic problems involving
two numbers and one of the four basic arithmetic operations (addition, subtraction,
multiplication and division). The user tries to answer each problem and garners
“points” for correct ones. The program counts all correct and incorrect answers ,
tallies them, then reports the result. The program then asks the user whether to exit or
run the tutorial again.
Upon running the program, the user will be asked whether the beginner mode
or advanced mode is to be used. The beginner mode presents problems that are
relatively easy to answer and asks more addition and subtraction than multiplication
and division. Advanced mode asks relatively harder questions. The user is then asked
how many problems he/she wishes to answer. Thereafter, the program generates
enough random arithmetic problems in the given difficulty level as specified by the
user.
IV. Implementation
A tutorial program that generates the same problems over and over again each
time you run it will obviously be less than useful. This application requires our
program to generate (pseudo)random numbers. The following code illustrates how to
do such in C.
#include <stdlib.h>
#include <time.h>
int main()
{
int r1, r2, r3;
srand( time(NULL) ); /*sets the seed to the current
time*/
r1 = rand()%100+1; /* 1 <= r1 <= 100 */
r2 = rand()*100+1; /* 1 <= r2 <= 100, r2 is 'more'
random than r1 */
r3 = rand()*50; /* 0 <= r3 < 50 */
return 0;
}
Note that srand(time(NULL)) has to be called only once, at the start of the
program before making any calls to rand(). Its job is to provide a random number
generator with a seed value taken from the current time stored in the computer’s
clock. So unless you run the program at exactly the same time each day, the rand()
function will generate a different sequence of numbers every time.
One way by which you can make things easier for the user is to make sure that
your division problems have an integer quotient. You can’t really expect your target
user (e.g. children) to answer problems like 417 /324, do you?
Assume that the user will always input integers but make sure to consider
other possible, yet avoidable, exceptions.
C> atutor
Welcome to Narutard's Arithmetic Tutorial!
(B)eginner or (A)dvanced? B
How many problems? 3
What is 3 x 1? 3
What is 21 / 7? 7
What is 2 + 0? 2
You correctly answered 2 out of 3 problems, or 67%.
Do you wish to run the tutorial again (Y/N)? N
Thank you for using Narutard's Arithmetic Tutorial!
V. Documentation
Functionality 50%
Algorithm Design 25%
External Documentation 15%
User Interface 5%
Code Readability 5%
100%
On this programming project, the grade will be reduced by 10% for every day late
submission excluding weekends. Deductions will continue to accrue until the project is finally
submitted (even if it results to a negative grade.) On the other hand, early submissions will be
given +2% for each day earlier than the due date (maximum of 10%).
VII. Deliverables
A novice asked the master: “I have a program that sometimes runs and sometimes aborts. I have followed the
rules of programming, yet I am totally baffled. What is the reason for this?”
The master replied: “You are confused because you do not understand Tao. Only a fool expects rational behavior
from his fellow humans. Why do you expect it from a machine that humans have constructed? Computers simulate
determinism; only Tao is perfect.”
“The rules of programming are transitory; only Tao is eternal. Therefore you must contemplate Tao before you
receive enlightenment.”
“But how will I know when I have received enlightenment?” asked the novice.
“Your program will then run correctly”, replied the master.
- 4.3, The Tao of Programming