Java Programming

Problem Need Solution

  • (2 Pages)
  • +
  • 1
  • 2

18 Replies - 1099 Views - Last Post: 02 November 2008 - 06:31 AM Rate Topic: -----

#1 javabeginner1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 01-November 08

Java Programming

Posted 01 November 2008 - 05:06 PM

This is the program that i have construct but having error. The error points to first line and says


import.java.io.*;
^
'.' expected

import.java.io.*;
^
<identifier> expected
import.java.text.NumberFormat;
^
'.' expected
import.java.text.NumberFormat;
^
4 errors

Process completed.


<codes taken off>

This post has been edited by javabeginner1: 02 November 2008 - 01:48 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Java Programming

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Java Programming

Posted 01 November 2008 - 05:12 PM

no "." after the import statement

import java.io.*;
import java.text.NumberFormat;
import java.lang.Math;
Was This Post Helpful? 0
  • +
  • -

#3 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2675
  • View blog
  • Posts: 11,305
  • Joined: 20-September 08

Re: Java Programming

Posted 01 November 2008 - 05:12 PM

import.java.io.*;

should be

import java.io.*;
Was This Post Helpful? 0
  • +
  • -

#4 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Java Programming

Posted 01 November 2008 - 05:13 PM

there's no '.' after import
import java.io.*;
import java.text.NumberFormat;


Was This Post Helpful? 0
  • +
  • -

#5 javabeginner1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 01-November 08

Re: Java Programming

Posted 01 November 2008 - 05:15 PM

View Postpbl, on 1 Nov, 2008 - 05:12 PM, said:

no "." after the import statement

import java.io.*;
import java.text.NumberFormat;
import java.lang.Math;




Thanks. Never notice that and been cracking my head over night.

But now i have more problem..

--------------------Configuration: <Default>--------------------

String reply = input.readline();
^
operator == cannot be applied to java.lang.String,char
} while (reply=='Y' || reply=='y');
^
operator == cannot be applied to java.lang.String,char
} while (reply=='Y' || reply=='y');
^
NumberFormat numFormat = new NumberFormat.getInstance();
^
String temp = input.readline();
^
nextGuessNumber = tempNum.intvalue;
^
6 errors

Process completed.

This post has been edited by javabeginner1: 02 November 2008 - 01:56 AM

Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Java Programming

Posted 01 November 2008 - 05:19 PM

you cannot compare String with ==
you'll have to use the String equals method or equalsIgnorecase

String x;
String y;

if(x.equalsIgnoreCase(y))
.....
Was This Post Helpful? 1
  • +
  • -

#7 javabeginner1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 01-November 08

Re: Java Programming

Posted 01 November 2008 - 05:30 PM

Thank you and i have changed as below and the error for this solve


But still having error. Cannot resolve symbol. I have import the needed items at the first line but still having errors below


--------------------Configuration: <Default>--------------------
cannot resolve symbol
symbol : method readline ()
location: class java.io.BufferedReader
String reply = input.readline();
^
cannot resolve symbol
symbol : class getInstance
location: class java.text.NumberFormat
NumberFormat numFormat = new NumberFormat.getInstance();
^
cannot resolve symbol
symbol : method readline ()
location: class java.io.BufferedReader
String temp = input.readline();
^
cannot resolve symbol
symbol : variable intvalue
location: class java.lang.Number
nextGuessNumber = tempNum.intvalue;
^
4 errors

Process completed.

This post has been edited by javabeginner1: 02 November 2008 - 01:50 AM

Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Java Programming

Posted 01 November 2008 - 05:38 PM

the method in Buffered Reader id readLine() not readline();

didn't know that NumberFormat had a getInstance() method ... if it is the case you get an instance of an already existing NumberFormat() so there in no "new" there

NumberFormat numFormat = NumberFormat.getInstance();

I presume that intvalue should be intValue
Was This Post Helpful? 1
  • +
  • -

#9 javabeginner1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 01-November 08

Re: Java Programming

Posted 01 November 2008 - 05:41 PM

Anybody willing to help me sort out this errors
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8327
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Java Programming

Posted 01 November 2008 - 05:43 PM

answered one reply before
Was This Post Helpful? 0
  • +
  • -

#11 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Java Programming

Posted 01 November 2008 - 05:45 PM

pbl beat me and mentioned the errors :P, your code should work nicely now
Was This Post Helpful? 0
  • +
  • -

#12 javabeginner1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 01-November 08

Re: Java Programming

Posted 01 November 2008 - 06:03 PM

Yes Pbl. You have been very helpful.

You are right on the readline => readLine, no new in NumberFormat() and intvalue => intValue.

But i still have one error


--------------------Configuration: <Default>--------------------
cannot resolve symbol
symbol : variable intValue
location: class java.lang.Number
nextGuessNumber = tempNum.intValue;
^
1 error

Process completed.

Do i need to include something like import java.lang.Number (not sure on this).


The NumberFormat and getInstance() method i refferd to a book by James M. Slack (Programming and Problem Solving with JAVA), 1st edition, ISBN No. 0534374867.


Page 353





pbl and mostyfriedman

really appreciate your feedback

This post has been edited by javabeginner1: 02 November 2008 - 01:51 AM

Was This Post Helpful? 0
  • +
  • -

#13 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Java Programming

Posted 01 November 2008 - 06:12 PM

intValue(); add brackets because this is a method

and also you dont have to import any classes from the lang package because it is implicitly imported by the compiler in every java program you write, this should save you some typing in the future...also i would recommend this book for you..java how to program 6th edition, its a great book with many examples, check it out

This post has been edited by mostyfriedman: 01 November 2008 - 06:15 PM

Was This Post Helpful? 1
  • +
  • -

#14 javabeginner1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 01-November 08

Re: Java Programming

Posted 01 November 2008 - 06:16 PM

sorted out the intValue. it was mission the (). Suppose to be intValue()


Thanks. Still working on it and will revert back if i encounter any new problems.

Thanks once again Pbl

Thanks mostyfreidman.

can you give the author and isbn number of the book that you have recommend

java how to program 6th edition

so that i can find in the online library
Was This Post Helpful? 0
  • +
  • -

#15 mostyfriedman  Icon User is offline

  • The Algorithmi
  • member icon

Reputation: 727
  • View blog
  • Posts: 4,473
  • Joined: 24-October 08

Re: Java Programming

Posted 01 November 2008 - 06:24 PM

Java™ How to Program, Sixth EditionBy H.áM.áDeitel - áDeitel & Associates, Inc., P.áJ.áDeitel - áDeitel & Associates,
Inc.Publisher: Prentice Hall
Pub Date: August 04, 2004
Print ISBN-10: 0-13-148398-6
eText ISBN-10: 0-13-128933-0
Print ISBN-13: 978-0-13-148398-9
eText ISBN-13: 978-0-13-128933-8

lol i just copied this info from the book, i dont know which isbn to use..but you will fall in love with this book i guarantee it.. btw thank you for your kindness my brother, but i'm not a genius..still learning and still got a lot to learn but thank you for ur kind words..if u have any more questions dont hesitate to ask

This post has been edited by mostyfriedman: 01 November 2008 - 06:30 PM

Was This Post Helpful? 1
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2