10/02/09 – Program I

Problem:

Mr. Statos’s 5th grade class has just finished learning multiplication and division by 12. You want to write a program that will generate quizzes for his students that will test all four arithmetic operations – addition, subtraction, multiplication, and division.

The quiz will have 50 questions. The questions will involve the four arithmetic operations randomly. You will also generate two operands. The requirements for the operands are as follows:

  • Addition: Both operands are positive two digit numbers.
  • Subtraction: Both operands are positive two digit numbers. Arrange the subtraction so that the user is subtracting the smaller number from the bigger number.
  • Multiplication: Both operands are positive numbers in the range 0 through 12, both numbers inclusive.
  • Division: The dividend (numerator) will be a positive two digit number. The divisor (denominator) will be a number in the range 1 through 12, both numbers inclusive. For division, we are interested only in the quotient and not in the remainder.

Your program will number each question that it prints out. It will read the answer the user inputs. If the answer is wrong, it will print the correct answer. The program will keep a tally of how many questions the user gets correct. It will print the total score at the end.

If the user gets 46 to 50 questions correct, your program will print Great Job. If the user gets 40 to 45 questions correct, your program will print Good Attempt. If the user gets less than 40 questions correct, your program will print Better effort next time.

Your program should also give the user the option of trying another quiz. If the user decides on another quiz, then a fresh quiz is generated. If the user decides to quit, then the program thanks the user for taking the quiz.

My Solution

This is probably not the most efficient solution. You should try to write a better solution.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: