Anne
Dawson: CSCI101A_HW1_SP05.htm
First
created: Friday 14th January 2005, 7:40 PT, AHD
Last updated: Monday
24th January 2005, 6:57 PT, AHD
This
document is subject to change without notice.
Please
report any errors or omissions in this document to
adawson@coquitlamcollege.com
For due
date, see course schedule.
Special
instructions: Each student must
complete this homework.
CSCI101A
Homework 1
-------------------
Specification:
-------------
Write a
program (HW1.cpp) that will help an elementary school student learn
multiplication. Your program will
generate two random numbers in the range 1 to 9. It should then display a question such as:
How
much is 6 times 7?
The
student then types the answer.
Your program checks the student's answer. If it is correct, the text
"Very good!" is displayed followed by the next multiplication
question. If the answer is wrong, display the text "Incorrect answer. The
correct answer is X." where X is the correct answer, before moving on to
the next question. The program displays ten questions, and then displays the
resulting score out of ten as a percentage. If the percentage is 70% or more, display the text
"Well done! Keep up the good work!" otherwise the text "Please
see your instructor for extra help" should be displayed.
Your
main program should call the functions getNumber and doTheMath. The headers of
these functions are as follows:
int
getNumber( void )
bool
doTheMath( int num1, int num2)
getNumber
returns a random integer number in the range 1 to 9. You should study the
program:
http://www.coquitlamcollege.com/adawson/random.cpp
for an example of random number generation in C++ using the Borland environment. If you're
using the Dev-C++ environment, study this program:
http://www.coquitlamcollege.com/adawson/random_devcpp.cpp
doTheMath
receives two random numbers, displays the multiplication question using these
two numbers, and returns a Boolean value; doTheMath returns the value true if
the student correctly answers the question, otherwise it returns the Boolean
value false.
The
main function calls the getNumber and doTheMath functions, and calculates and
displays the result.
Marking
Scheme :
--------------
The
following marking scheme applies:
Course
Code: CSCI101A
Semester: SP05
Assignment
Code: HW1
Instructor
Name: Dr Anne Dawson
Student
Name:
Student
Number:
DESIGN
1. The program has appropriate modularity
i.e. functions are used
where it makes sense to use them.
/10
2. Appropriate data types are used.
/10
3. Appropriate control structures are used
(i.e. loops and
decisions).
/10
4. The User Interface (output to the screen)
is
clear and tidy.
/10
MAINTAINABILITY
5. The program is commented appropriately
- including
date, filename and pre- and
post-condition
comments.
/10
6. The program has meaningful
identifiers.
/10
7. The program is indented (spaced out)
correctly, to
aid the understanding of
the code.
/10
8. The code is easy to follow.
/10
CORRECTNESS:
9. The program compiles with 0 errors and
0 warnings. /10
10.
Appropriate test data and results are shown in
the comments at the top of
the code.
An appropriate number and
variety of test data
sets is supplied.
/10
% Complete:
Total:
/100
Date: