Hello everyone,
I'm a beginner at Java and have a question. I have an optional exercise I can do for uni to create a program and am stuck as to what to use to get the program to work. The question is asking me to do it using selection? I am pretty sure selection is like for sorting by a letter or something. Here is my code:
package movieprogram; import java.util.Scanner; public class MovieProgram { public static void main(String[] args) { // TODO code application logic here Scanner scanner1 = new Scanner(System.in); System.out.println("What is your name?"); String name1 = scanner1.next(); System.out.println("What is your mobile number?"); int number = scanner1.nextInt(); System.out.println("What is your age?"); int age = scanner1.nextInt(); System.out.println("What is the name of the movie?"); String movie = scanner1.next(); Scanner scanner2 = new Scanner(System.in); System.out.println("What is the time of the movie"); int time = scanner2.nextInt(); int ticketPrice = 20; if (age < 18) ticketPrice = 20/2; System.out.println("You are under 18 so you get 50% off!" + "Your price is: " + ticketPrice); else if (age >= 18 && age <= 65) ticketPrice = 20; System.out.println("Your price is " + ticketPrice); else if (age > 65) ticketPrice = 15; System.out.println("You are over 65. Your price is: " + ticketPrice); } }
The question is
1. MOVIE TICKETS: Describe the process of booking a movie ticket. The user must be asked for their name, mobile number and age. The user will be asked to provide a movie name and time. If the user is under 18, the movie ticket price is halved ($10). If the user is between 18 and 65, the movie ticket is normal ($20), if the user is over 65, the movie ticket is three quarters of the normal price ($15).