Tutorial Week 6 - Introduction to Repetition


Home


For the following questions, work through steps 1 (Understanding) through 5 (Desk Checking) of the Steps in Program Development discussed in lectures.

Question 1

Problem Description

Write a program to display the times table (from 1 to 12) for the number input. When performing the desk check, only do up to 3, not 12 (e.g. 1 x 6, 2 x 6, 3 x 6).

Example Runs

Run
Times table ? 6

6 Times Table
1 x 6 = 6
2 x 6 = 12
3 x 6 = 18
...
12 x 6 = 72
Run
Times table ? 11

11 Times Table
1 x 11 = 11
2 x 11 = 22
3 x 11 = 33
...
12 x 11 = 132

Question 2

Problem Description

Write a program to calculate the total of a series of students marks. The user initially inputs the number of marks to be input. Students' marks are whole numbers. Assume marks input by the user are valid.

Example Runs

Run
Number of marks ? 4
Running total = 0
Mark (0 to 100) ? 80
Running total = 80
Mark (0 to 100) ? 60
Running total = 140
Mark (0 to 100) ? 45
Running total = 185
Mark (0 to 100) ? 95
Running total = 280

Total marks = 280

Question 3

In the previous question what would happen if a negative mark, such as -80 was input?


Written by Tim Whitfort.