Question Three
[12 Marks]
You are designing a basic login system. The system stores a username and password in two
separate variables and allows a user to log in by entering the correct credentials (username
and password).
• If the credentials are incorrect, the user is given up to 3 attempts to enter the correct
username and password.
• If the user fails all 3 attempts, print a message saying, "The account is locked!".
• Otherwise print a message saying, "Login Successful."
Below is the username and password. Declare variables to store the username and
password and assign the values as follows:
Username: student
Password: 12345
Write a Java program that prompts the user for a username and password, and checks
whether they match the stored credentials.
Question Four
[20 Marks]
You are tasked with creating a simple movie ticket booking system. The system allows
customers to book tickets for a specific movie. The movie prices vary based on age:
• Children (under 12 years old) pay NAD 80.00,
• Adults (12 to 65 years old) pay NAO 120.00,
• And seniors (over 65 years old) pay NAD 100.00.
Declare a static method named calculatePrice(age) that takes age as a parameter and
returns the price of the movie ticket based on the age. This method MUST NOT be void, it
must return the price of the movie ticket.
Next, declare a static method named bookTicket{price, numberOfTickets) that takes the
price and number of tickets as parameters and calculates and display/print the total cost of
the tickets based on the price and the number of tickets requested. This method MUST be
void.
Write a complete Java program to implement this movie ticket booking system. Your
solution must include methods calls.
****************************** ENDOF EXAM********************************
Page11 of 11