Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2008, 09:34 AM
Member
 
Join Date: Jun 2008
Location: Ontario Canada
Posts: 2
jlgraham is on a distinguished road
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);

}

}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 06-29-2008, 09:44 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Error in comments. Change \\ into // and see.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 06-29-2008, 09:52 AM
Member
 
Join Date: Jun 2008
Location: Ontario Canada
Posts: 2
jlgraham is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 06-29-2008, 10:04 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,875
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Nice! If you solve the question please mark the thread as solved.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
(Close on September 4, 2008)

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
illegal character: \65279 iwax New To Java 3 01-30-2008 03:52 PM
reading text character by character bugger New To Java 2 11-09-2007 09:54 PM
Illegal Start of an Expression David55 CLDC and MIDP 8 11-02-2007 10:11 PM
Illegal start of expression gabriel New To Java 2 08-01-2007 06:09 PM
Illegal Start of an Expression David55 CLDC and MIDP 0 04-20-2007 06:59 AM


All times are GMT +3. The time now is 02:40 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org