[go: up one dir, main page]

0% found this document useful (0 votes)
18 views2 pages

Selection Control Structure

computer science selection control structue

Uploaded by

joanasattar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Selection Control Structure

computer science selection control structue

Uploaded by

joanasattar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Questions- Selection Control Structure

1. The cost of a day-time journey is £3 for the first kilometre and £2 for every kilometre after that.
If there are five of more passengers in the taxi, and extra 50% is added to the charge.

Write an algorithm to calculate the cost of a day-time journey.

Your algorithm should:

 Allow the number of passengers and he distance of the journey to be input as whole
numbers,
 Calculate the cost of the journey,
 Output the cost that has been calculated.

2. The wages earned by a worker is either £2 for every teddy bear the have made or £5 for
every hour they have worked, whichever is larger.

Write an algorithm that:

 allows the user to input the number of teddy bears made and the number of hours
worked
 calculates the wages for the number of teddy bears made
 calculates the wages for the number of hours worked
 outputs the larger of the two results.

(3) There are ten stations on a railway line:


1 ------ 2 ------ 3 ------ 4 ------ 5 ------ 6 ------ 7 ------ 8 ------ 9 ------ 10
The train travels in both directions (i.e. from 1 to 10 and then from 10 to 1). The fare between
each station is $2. A passenger inputs the number of the station at the start of his journey and
the number of the destination station and the fare is calculated (e.g if a passenger gets on a
station 3 and his destination is station 9 his fare will be $12). The calculation must take into
account the direction of the train (e.g. a passenger getting on at station 7 and getting off at
station 1 will also pay $12 and not a negative value!!).
A discount of 10% is given if 3 or more passengers are travelling together.
Write an algorithm, using pseudocode, which:
• inputs the number of passengers travelling
• inputs the station number of the starting point and the station number of the destination
• calculates the total fare taking into account the direction of travel
• calculates any discount due
• outputs the cost of the tickets and prints the tickets

4. You are writing a program for an airline that


 Inputs Weigh, Length and Width of a baggage
 Calculates the price for oversized baggage (if any) that air travellers have to pay.
The rules are given as follows:
 Any baggage that is under 10 kg and is no larger than 40 by 30 cm, ignoring depth, can
go free of charge.
 Any baggage that doesn’t satisfy the first criteria, up to 20 kg and 60 by 40 cm, costs
£50.
 Any baggage that doesn’t satisfy the first and second criteria, is charged £10 per kg.
 Baggage over 100 kg and 150 by 150 cm is not allowed at all and should be sent
separately by freight.

5. Allow the user to enter the temperature in Centigrade (no validation is required)

 Validate that the temperature entered is between 0 and 100 Centigrade (no other
validation is required and both 0 and 100 are to be treated as valid temperatures)
 Convert the temperature to Fahrenheit by the following formula:
Fahrenheit = Centigrade x (9 ÷ 5) + 32
 If a valid temperature is entered, output the converted temperature in Fahrenheit
 Otherwise output "Temperature must be between 0 and 100"
 The program does not need to ask the user to enter the temperature again if they enter
an invalid number

You might also like