Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving string and compilation errors on Java program
    text
    copied!<p>I tried compiling this, and got an error saying: $javac Question2.java 2>&amp;1 Question2.java:55: error: reached end of file while parsing } ^ 1 error TYPE CANNOT BE RESOLVED TO A VARIABLE</p> <p>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.</p> <p>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.</p> <pre><code>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") &amp;&amp; (type == "student")) { double standard_student = standard * 0.95; } if ((ticket == "standard") &amp;&amp; (type == "pensioners")) { double standard_pensioners = standard * 0.90; } if ((ticket == "restricted") &amp;&amp; (type == "student")) { double restricted_students = restricted * 0.95; } if ((ticket == "restricted") &amp;&amp; (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!"); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload