Results 1 to 13 of 13
Thread: in need of Help
- 09-05-2008, 01:28 AM #1
Member
- Join Date
- Sep 2008
- Posts
- 7
- Rep Power
- 0
in need of Help
:confused::confused::confused::(:(:(
import.java.util.*;
public class Celsius
{
static Scanner console = new Scanner(System.in);
public static void main (String[] args)
{
double F;
double C;
System.out.println("Enter the temp in F");
F = console.next double();
System.out.println();
C=(5/9.)*(F-32);
System.out.println(" The temperature in celsius is: " + C);
System.out.printf("num = %.2f %n", F,C);
- 09-05-2008, 01:48 AM #2
Java Code:import java.util.Scanner; public class CelsiusRx { static Scanner console = new Scanner(System.in); public static void main (String[] args) { double F; double C; System.out.println("Enter the temp in F"); F = console.nextDouble(); System.out.println(); C=(5/9.0)*(F-32); System.out.println(" The temperature in celsius is: " + C); System.out.printf("num = %.2f %n", F,C); } }
- 09-05-2008, 02:03 AM #3
Member
- Join Date
- Sep 2008
- Posts
- 7
- Rep Power
- 0
The code is supposed to promt the user to enter the temp,
then output the temp in degrees C and F, and format in to two decimal places.
I'm having trouble filing in the blanks.:(
- 09-05-2008, 02:30 AM #4
The code is supposed to promt the user to enter the temp,
You seem to have that working okay.
then output the temp in degrees C and F, and format in to two decimal places.
I'm having trouble filing in the blanksJava Code:System.out.printf("num = %.2f %n", F,C); // try System.out.printf("F = %.2f C = %.2f%n", F, C);
Which blanks now?
- 09-05-2008, 02:36 AM #5
Member
- Join Date
- Sep 2008
- Posts
- 7
- Rep Power
- 0
I'm sorry.
I feel so pathetic, cause this code is so simple. THANKS FOR HELPING ME!!!!!
Should there be any other statements for C?
The format to dec looks good but is the output for C and F right or do I need something else?
GD. I suck @ this.
- 09-05-2008, 02:38 AM #6
Member
- Join Date
- Sep 2008
- Posts
- 7
- Rep Power
- 0
Here's the syntax error that I'm getting.
----jGRASP exec: java Celsius
java.lang.NoClassDefFoundError: Celsius
Caused by: java.lang.ClassNotFoundException: Celsius
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
- 09-05-2008, 02:57 AM #7
Is there a file named Celsius.class in the folder where you are entering the java command? The java command can't find it.
- 09-05-2008, 03:05 AM #8
Member
- Join Date
- Sep 2008
- Posts
- 7
- Rep Power
- 0
No sir. I created this class.
- 09-05-2008, 03:06 AM #9
Member
- Join Date
- Sep 2008
- Posts
- 7
- Rep Power
- 0
class name
- 09-05-2008, 03:18 AM #10
What is the full filename of the class file you created?
- 09-05-2008, 03:22 AM #11
Member
- Join Date
- Sep 2008
- Posts
- 7
- Rep Power
- 0
Celsius.java
- 09-05-2008, 02:17 PM #12
There is confusion between source and class files.
Celsius.java is the source file, not a class file.
To execute it you need first to compile it with the javac command:
javac Celsius.java
If there are no errors, javac will create Celsius.class.
Then you can execute it by entering: java Celsius
- 09-05-2008, 04:56 PM #13
Senior Member
- Join Date
- Aug 2008
- Posts
- 384
- Rep Power
- 5


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks