CHALLENGE
You
have the option to do any one of the programs below. Please notice the mark that you get depends
on the option that you do.
You
are NOT allowed to use IF STATEMENTS!
OPTION 1 (4 out
of 5 marks)
Write
a program that will ask the user for two integers. The program then outputs the difference
between the larger number and the smaller number.
SAMPLE OUTPUT
Enter 2 integers.
42
12
The difference is 30.
|
SAMPLE OUTPUT 2
Enter 2 integers.
12
42
The difference is 30.
|
SAMPLE OUTPUT 3
Enter 2 integers.
-4
5
The difference is 9.
|
OPTION 2 (4.5 out
of 5 marks)
Write
a program that will ask the user for three integers. The program then outputs the sum of the
smallest and the largest numbers.
SAMPLE OUTPUT
Enter 3 integers.
42
8
12
The sum is 50.
|
SAMPLE OUTPUT 2
Enter 3 integers.
-4
17
-8
The sum is 9.
|
SAMPLE OUTPUT 3
Enter 3 integers.
4
8
6
The sum is 12.
|
OPTION 3 (5 out
of 5 marks)
Write the program that will ask the user for three integers. The program then outputs the number that is
in the middle of the three.
SAMPLE OUTPUT
Enter 3 integers.
42
8
12
The middle number is 12.
|
SAMPLE OUTPUT 2
Enter 3 integers.
-4
17
-8
The middle number is -4.
|
SAMPLE OUTPUT 3
Enter 3 integers.
8
6
1
The middle number is 6.
|
|