Cover for Monday 9th September

Block A: Computer Programming (Room 3030)

Students can continue with graded problems (on this blog together with examples for reference).

Here are some more problems to work on:

BEGINNER

Write a program that asks for an integer from the user and prints out the multiplication table for that number, up to 12:

Example:

Input:

7

Output:

1 x 7 = 7
2 x 7 = 14
3 x 7 = 21
4 x 7 = 28
5 x 7 = 35
6 x 7 = 42
7 x 7 = 49
8 x 7 = 56
9 x 7 = 63
10 x 7 = 70
11 x 7 = 77
12 x 7 = 84

Adapt your program so that the number that your multiplication table goes up to is configurable (ie the previous output would now be got by entering 7 and 12 instead of just 7.

INTERMEDIATE

Write a program that accepts an arbitrary number of integers from the user and prints out the mean, median, and mode. (Note: to use the first input method you will need to use the String.split() method from the Java API.)

Example:

Input: (Method 1)

3 4 7 7 7 7 9 9 10 10 12

Input: (Method 2)

Enter a number (0 to quit):
3
Enter a number (0 to quit):
4
Enter a number (0 to quit):
7
etc.

Output:

n: 11
Total: 85
Mean: 7.7272727272727272727272727272727
Median: 8
Mode: 7

ADVANCED

Implement the game of tic-tac-toe / noughts and crosses for two human players (using the same computer).

Hints:
Model the board as a 9-element array.
Use the following algorithm:

Get the first move
While (fewer than nine moves have been made) 
   Check that the game isn't over
   Get another move
}

Now think about how you would write a computer player.

Block B: IB1 Computer Science (Room 3030)

Revise for quiz on Topics 2 and 3 tomorrow (Tuesday)

Block C: IB 2 Computer Science (Room 3030)

Work on program dossier.

Block E: Integrated Mathematics 2 (Room 4013)

Students to continue work on piecewise functions sheets. Jenna, thanks for doing this. Please feel free to teach this lesson as you see fit, or just let the class get on with it. They have been given a full introduction to the topic although one or two of them might try telling you they haven’t!

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 )

Connecting to %s