Hartismere School

An outstanding coeducational secondary school and sixth form college

2 Using IF Statements

Program 1

Create a program that allows the user to enter a student test mark. The test is out of 100. If the students gets a mark of 50 or more they pass, otherwise they fail. Output whether they pass.

Program 2

Write a program to ask the user what 24+9 is. Say “Excellent” if they get it right.

Program 3

Write a program to ask the user to enter their age. If their age is under 18 then say “Sorry, this film is not for you”.

Program 4

Write a program to ask the user for two numbers. Compare the first with the second and then print out one of three messages. Either the numbers are equal, the first is bigger, or the second is bigger. You will need more than one IF to solve this one.

Program 5

Write a program that will allow the user to enter and username and password. If the username is "user" and the password is "password", output that they have logged in. Otherwise say that the details are incorrect. 

Program 6

Write a program which asks the user to enter a number between 1 and 10. If the number entered is out with this range then display a message “Sorry…out of range”.