Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: need help with simple multiple choice

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help with simple multiple choice

    I am making a simple multiple choice quiz for a school project and i keepgetting: Syntax error: Unexpected token ILLEGAL. I dont know whats wrong. Heres the code:

    var Question1 = prompt("What is (40 / 2) + 6:
    A:5
    B:10
    C:26
    D:None of these");
     
    var question1 = Question1.toUpperCase
    switch (question1)
      {case "A":
          answer1 = "A"
          break;
         case "B":
             answer1 = "B"
             break;
        case "C":
            answer1 = "C"
            break;
        case "D":
            answer1 = "D"
            break;
        default:
     
     
      }
      console.log(answer1)


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: need help with simple multiple choice

    javascript is not java
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member Abhilash's Avatar
    Join Date
    Jun 2014
    Location
    Kolkata, West Bengal, INDIA
    Posts
    108
    My Mood
    Busy
    Thanks
    5
    Thanked 10 Times in 10 Posts

    Lightbulb Re: need help with simple multiple choice

    Sorry, but you cannot print options in different lines in this way.
    You can only print printing statements in one line. So either your can print the options in one line or print them in different lines using individual printing statements.

Similar Threads

  1. Is scanner the right choice?
    By Badformat in forum Java Theory & Questions
    Replies: 1
    Last Post: January 20th, 2014, 04:02 PM
  2. [SOLVED] simple question, coding unrelated, how to delete multiple tabs?
    By Perd1t1on in forum Java Theory & Questions
    Replies: 1
    Last Post: September 8th, 2010, 07:44 PM
  3. Which interface gives more control on serialization of an object?
    By abhishekraok2003 in forum Java Theory & Questions
    Replies: 1
    Last Post: May 16th, 2009, 10:17 AM
  4. Replies: 2
    Last Post: May 16th, 2009, 05:23 AM