Results 1 to 4 of 4
  1. #1
    jlgraham is offline Member
    Join Date
    Jun 2008
    Location
    Ontario Canada
    Posts
    2
    Rep Power
    0

    Default illegal character: \92

    I had my application working just fine and all I did was change the phrase in my System.out.println() and now I get this error. I changed everything back to the original and still get this error on each of my statements. TestNumbers.java:18 illegal character:\92 double num1 = input.nextDouble(); \\This will give input a double type. It will throw an exception if letters are added. Why did it work once? Can someone help as this assignment is due on Monday. Code follows
    import java.util.*;

    //this class does the required calculation as requested
    public class TestNumbers
    {
    public static void main(String args[])
    {

    Scanner input = new Scanner(System.in);

    System.out.println();
    System.out.println("Enter a number that is a double:");
    double num1 = input.nextDouble(); \\This will give input a double type. It will throw an exception if letters are added

    System.out.println();
    System.out.println("Enter a number that is a float:");
    float num2 = input.nextFloat(); \\This will give input a float type. It will throw an exception if letters are added

    System.out.println();
    System.out.println("Enter a number that is a long:");
    long num3 = input.nextLong(); \\This will give input a long type. It will throw an exception if letters are added

    System.out.println();
    System.out.println("Enter a number that is an integer:");
    int num4 = input.nextInt(); \\This will give input an int type. It will throw an exception if letters are added

    System.out.println();
    System.out.println("Enter a number that is a byte:");
    byte num5 = input.nextByte(); \\This will give input a byte type. It will throw an exception if letters are added

    float result1 = num2 - num4;
    double result2 = result1 * num1;
    double result3 = result2 / num3;
    double result4 = result3 * num5;
    double result5 = result4 / 2;
    int result = (int)result5; \\to be sure result is an integer, it is expicitly stated

    System.out.println();
    System.out.println("Result of (float-int)*double/long*byte/2 is:\n\n" + result);

    }

    }

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

  3. #3
    jlgraham is offline Member
    Join Date
    Jun 2008
    Location
    Ontario Canada
    Posts
    2
    Rep Power
    0

    Default

    I feel so stupid. It worked before I commented. Thanks! At 63 years old I find this course really hard but am enjoying it. Hopefully this forum will keep me out of the insane asylum.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    19

Similar Threads

  1. illegal character: \65279
    By iwax in forum New To Java
    Replies: 3
    Last Post: 01-30-2008, 02:52 PM
  2. reading text character by character
    By bugger in forum New To Java
    Replies: 2
    Last Post: 11-09-2007, 08:54 PM
  3. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 8
    Last Post: 11-02-2007, 09:11 PM
  4. Illegal start of expression
    By gabriel in forum New To Java
    Replies: 2
    Last Post: 08-01-2007, 05:09 PM
  5. Illegal Start of an Expression
    By David55 in forum CLDC and MIDP
    Replies: 0
    Last Post: 04-20-2007, 05:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •