Ride height

Ride height

Are you tall enough for a ride at an amusement park?

Try


Select the button below to open the C# program in a new window. Run the program and read the lines of code to see if you can understand how it works. It will be helpful to arrange your display so that you can have this browser window on one side of the screen and the code on the other.

Watch this video to learn about the new concepts shown in the program:

Knowledge Organiser

Command summary

The new commands used in this program and others that may be useful. Select them below to learn more:

if, else if, else

if (x < y)

{

// If the value of x is less than the value of y, execute this code.

}

if (x > y)

{

// If the value of x is greater than the value of y, execute this code.

}

else {

// If no condition is met, execute this code instead.

}

Code must be inside of the curly brackets and indented. Only one part of the code will be run, the other part will be ignored.

Investigate


Questions to think about with this program to check your understanding:

Item question

Identify a condition in the program.

REVEAL ANSWER

`height > 104` is known as a condition. The outcome of a condition is either True or False.

Structure question

State the two essential parts of the `if` selection statement and two optional parts.

REVEAL ANSWER

Two essential parts of the `if` command:


  1. A condition
  2. Commands inside curly brackets to execute if the condition is true.


Two optional parts:


  1. An `else`
  2. Commands inside curly brackets to execute if the condition is false.

Make


Success Criteria

Change the program so that it works for a toddler's merry-go-round:

  1. The child must be under 91cm to go on the ride.

Typical inputs and outputs from the program would be:

Enter the height of the person in cm: 110

Sorry, you are too tall.


Enter the height of the person in cm: 78

Height OK.

Help

Use the flowcharts if you need more support in understanding the steps required to meet the criteria. Use the Parsons code sorting exercise only if you are really stuck.

Evaluate


Run your code to check that your program has met the success criteria and produces the required output.

Enter the height of the person in cm: 150

Sorry, you are too tall.

Enter the height of the person in cm: 83

Height OK.

Enter the height of the person in cm: 91

Sorry, you are too tall.

Enter the height of the person in cm: 90

Height OK.

Registered in England and Wales: 10442992

VAT Number: 290 9845 58

Telephone: 01452 947500

Email: admin@craigndave.co.uk

Bett Awards 2024 Finalist