| | |
Code is written, but not working.
![]() |
•
•
Join Date: Sep 2004
Posts: 6
Reputation:
Solved Threads: 0
ok the error is that it doesnt recognize the package class.
is there another way to get around the "package" stuff.. like are there other classes ( I THINK they're called classes, such a newb -- sorry) such as java.io.*; or something that can be put in place of the package stuff?
Thanks.
Java Syntax (Toggle Plain Text)
package celsiustofahrenheit; public class CelsiusToFahrenheit { public static void main(String args []) { double celsius, fahrenheit = 0; System.out.println("\n\tEnter temperature in celsius: "); celsius = MyInput.readDouble(); fahrenheit = 1.8 * celsius + 32; system.out.println("\n\tThat is " + fahrenheit + " degrees fahrenheit."); } }
is there another way to get around the "package" stuff.. like are there other classes ( I THINK they're called classes, such a newb -- sorry) such as java.io.*; or something that can be put in place of the package stuff?
Thanks.
•
•
Join Date: Sep 2004
Posts: 84
Reputation:
Solved Threads: 1
This implies you have a folder/directory called 'celsiustofahrenheit' and it contains your 'CelsiusToFahrenheit.java' file in it.
Packages organize classes into a hierarchy of related subsystems. In Java classes are placed in specific directories called packages.
A quick solution is you should be able to remove the package line from your source (for simplistic one classs applications.) Packages are best used when you have an application that is calling many support classes.
For example, you may have a file structure like:
com\yourname\convert
com\yourname\converters
Your main application/class (call it 'Convert.java') may reside in 'com\yourname\convert' and would contain a
package com.yourname.convert;
line. If you then call a class called 'CelsiusToFahrenheit.class' which resides in the 'com\yourname\converters' folder, you would then include (in the 'Convert.java' source,) an
import com.yourname.converters.*;
line. This is so the compiler can find the 'CelsiusToFahrenheit.class'.
Of course your 'CelsiusToFahrenheit.java' source has a
package com.yourname.converters;
line
Packages organize classes into a hierarchy of related subsystems. In Java classes are placed in specific directories called packages.
A quick solution is you should be able to remove the package line from your source (for simplistic one classs applications.) Packages are best used when you have an application that is calling many support classes.
For example, you may have a file structure like:
com\yourname\convert
com\yourname\converters
Your main application/class (call it 'Convert.java') may reside in 'com\yourname\convert' and would contain a
package com.yourname.convert;
line. If you then call a class called 'CelsiusToFahrenheit.class' which resides in the 'com\yourname\converters' folder, you would then include (in the 'Convert.java' source,) an
import com.yourname.converters.*;
line. This is so the compiler can find the 'CelsiusToFahrenheit.class'.
Of course your 'CelsiusToFahrenheit.java' source has a
package com.yourname.converters;
line
•
•
Join Date: Sep 2004
Posts: 6
Reputation:
Solved Threads: 0
Awesome!! ok, thank you. I fixed that problem quick. I just have one left. When i compile it it tells me this:
"C:\Documents and Settings\Booth\My Documents\java_programs\Ch3Ex9.java:13: cannot resolve symbol
symbol : variable MyInput
location: class Ch3Ex9
celsius = MyInput.readDouble();
^
1 error
Tool completed with exit code 1"
"C:\Documents and Settings\Booth\My Documents\java_programs\Ch3Ex9.java:13: cannot resolve symbol
symbol : variable MyInput
location: class Ch3Ex9
celsius = MyInput.readDouble();
^
1 error
Tool completed with exit code 1"
•
•
Join Date: Sep 2004
Posts: 84
Reputation:
Solved Threads: 1
According to your code snippet above, you need a class called MyInput with a readDouble method. I did not see this in your code above. I would assume you may have an additional java file called MyInput.java?? If so it will need to be in the same folder as the 'CelsiusToFahrenheit.java' code. (unless you figured out my rambelings about packages above.
•
•
Join Date: Sep 2004
Posts: 24
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by Maverick
ok the error is that it doesnt recognize the package class.
Java Syntax (Toggle Plain Text)
package celsiustofahrenheit; public class CelsiusToFahrenheit { public static void main(String args []) { double celsius, fahrenheit = 0; System.out.println("\n\tEnter temperature in celsius: "); celsius = MyInput.readDouble(); fahrenheit = 1.8 * celsius + 32; system.out.println("\n\tThat is " + fahrenheit + " degrees fahrenheit."); } }
is there another way to get around the "package" stuff.. like are there other classes ( I THINK they're called classes, such a newb -- sorry) such as java.io.*; or something that can be put in place of the package stuff?
Thanks.
Hi!
Your code is OK, but I think the program has problem whit
"celsius = MyInput.readDouble();"
I used another package and your program was OK.
bye
Peter
![]() |
Similar Threads
- checking repeating data in database (Visual Basic 4 / 5 / 6)
- saving list box2 data on the click of post button (Visual Basic 4 / 5 / 6)
- Design issue - checkers game (Java)
- Array problem... (C)
- How to execute the code written in a .py file. (Python)
Other Threads in the Java Forum
- Previous Thread: new to java
- Next Thread: zip file extraction
| Thread Tools | Search this Thread |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle physics plazmic print problem program programming project recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree trolltech unlimited utility webservices windows





