TMC - 10 Digital Tech Semester 2
Toggle Dark/Light/Auto modeToggle Dark/Light/Auto modeToggle Dark/Light/Auto mode

Sequence

from The Computing Zone

1. Three in, three out

Write a program that will allow a user to enter their name (string), their age (integer) and their favourite TV program (string). The program will then display the information entered and some additional text on separate lines. An example of the input and output from the program is shown below.

What is your name?
> Lister
What is your age?
> 39
What is your favourite TV program?
> Red Dwarf
Lister
is
39
years old and likes
Red Dwarf

2. Name swapper

Write a program that will ask the user to type in their first name and surname. The program will then display the two names in reverse order.

What is your first name?
> David
What is your surname?
> Tennant
Tennant David

3. Three in, three out (formatted)

Now edit program 1 so that the information entered is displayed differently as shown in the output box below. Note - your output will now have to display variables and text together.

What is your name?
> Lister
What is your age?
> 39
What is your favourite TV program?
> Red Dwarf
Lister 39
Likes watching Red Dwarf

4. Area of a rectangle

Ask your user to enter the length and width of a rectangle. Your program should calculate the area of the rectangle (length*width) and display the result with a suitable message.

Please enter the following values in cm.
Please enter the length of the rectangle.
> 12
Please enter the width of the rectangle.
> 6
The area of the rectangle is:
72 square centimetres

5. Area of a circle

Ask your user to enter the radius of a circle. Your program should use what they have entered to calculate the area of the circle (pi*radius*radius) and display the result.

Please enter the following values in cm.
Please enter the radius of the circle.
> 16
The area of the circle is:
803.84 square centimetres

6. Number cruncher

Write a program that inputs two individual integers between 0 and 9. The program should then combine the inputs to form a single number in a third variable. The program should show the equation of multiplying the three numbers together and the result, as shown in the example.

Enter the first number (0-9).
> 2
Enter the second number (0-9).
> 3
2 x 3 x 23 = 138

7. Address formatter

A program is required to format and store a users address in a single string. The user should be asked these questions:

What is your house number? What is the name of your street? What suburb/town do you live in? What is your postcode?

The program will then combine the user’s answers in a single string, formatted as shown in the example. The program will display the string on the screen.

What is your house number?
> 13
What is the name of your street?
> Aberlove Drive
What suburb/town do you live in?
> Buckhaven
What is your postcode?
> 4039
13 Aberlove Drive
BUCKHAVEN 4039

8. Super smart name swapper (extension)

Ask the user to enter their full name on one line, and display their name in reverse order.

What is your full name?
> David Tennant
Tennant David