
It looks like you're new here. If you want to get involved, click one of these buttons!
Ask the user to input either the lower or upper tier.
Ask the user their age in years.
If they are booking in the lower tier then seats for over 65’s will be £10 and below 16 are £5. All others are priced at £20.
For the upper tier, all tickets are increased by £5.
Console.writeLine("Which Tier"); string tier = Console.readLine(); Console.writeLine("Your Age"); int age = Console.readLine(); //Lower Part if (tier == "lower" && age> 65) { int price = £10; } elif (tier == "lower" && age < 16) { int price = £5; } elif (tier == "lower" && age > 16 && age < 65) { int price = £20; } //Upper Part if (tier == "upper" && age> 65) { int price = £15; } elif (tier == "upper" && age < 16) { int price = £10; } elif (tier == "upper" && age > 16 && age < 65) { int price = £25; }
hope this helps
And any correction is invited by anyone
Answers
Corrections:
elif is not a valid method, instead write else if.
int age will not work, you will have to use the parse method. Int16.Parse(value). Int16 can be replaced with Int32 and Int64 depending on the accuracy required.
Declare the int price outside the scope of (outside) the if statement to be able to reference it repeatedly and assign values to it outside the scope.
Don't write £ in the int declaration, only whole numbers.
Replaced > with >= because if the user enters 65 as age, no action will be applied and the price will be 0.
In the end, combine £ with the price value to get the result.
Also, in an if statement, you can skip the curly brackets for single statements but not for multiple statements.