I tried compiling this, and got an error saying: $javac Question2.java 2>&1 Question2.java:55: error: reached end of file while parsing } ^ 1 error TYPE CANNOT BE RESOLVED TO A VARIABLE
I am pretty sure the code is correct but there is a little thing I am missing. The program is meant to check the type of ticket (standard/vip/restricted) and discount(none/student/pensioner), if vip is selected, there is no discount, and there is 5% and 10% discounts for students and pensioners respectively, but I am unable to sort out the input methods, or type declarations.
Any sort of help is appreciated. PS, I am a student currently learning Java and cannot seem to find the exact solution to this problem, hence I've posted a question here.
import java.util.Scanner;
public class Question2 {
public static void main(String args[]){
Scanner userinput = new Scanner(System.in);
String ticket ;
System.out.print(" Type of Ticket: ");
ticket = userinput.next();
String discount;
System.out.print("What sort of discount do you have?");
discount = userinput.next();
int standard = 40;
int restricted = 20;
int VIP = 60;
if ((ticket == "standard") && (type == "student")) {
double standard_student = standard * 0.95;
}
if ((ticket == "standard") && (type == "pensioners")) {
double standard_pensioners = standard * 0.90;
}
if ((ticket == "restricted") && (type == "student")) {
double restricted_students = restricted * 0.95;
}
if ((ticket == "restricted") && (type == "pensioner")) {
double restricted_pensioner = restricted * 0.90;
}
if (ticket=="standard")
System.out.print("Your ticket costs $.");
if (ticket == "restricted")
System.out.print("Your ticket costs $.");
if (ticket== "VIP")
System.out.print("Your discount type cannot be used with your requested ticket type.");
System.out.println ("Thank you!");
}