Results 1 to 13 of 13

Thread: in need of Help

  1. #1
    tool_010 is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Cool 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);

  2. #2
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    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);
        }
    }

  3. #3
    tool_010 is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default

    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.:(

  4. #4
    hardwired's Avatar
    hardwired is offline Senior Member
    Join Date
    Jul 2007
    Posts
    1,576
    Rep Power
    8

    Default

    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.
    Java Code:
    System.out.printf("num = %.2f %n", F,C);
    // try
    System.out.printf("F = %.2f  C = %.2f%n", F, C);
    I'm having trouble filing in the blanks
    Which blanks now?

  5. #5
    tool_010 is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default 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.

  6. #6
    tool_010 is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default

    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.

  7. #7
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Is there a file named Celsius.class in the folder where you are entering the java command? The java command can't find it.

  8. #8
    tool_010 is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default

    No sir. I created this class.

  9. #9
    tool_010 is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default

    class name

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    What is the full filename of the class file you created?

  11. #11
    tool_010 is offline Member
    Join Date
    Sep 2008
    Posts
    7
    Rep Power
    0

    Default

    Celsius.java

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    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

  13. #13
    Supamagier is offline Senior Member
    Join Date
    Aug 2008
    Posts
    384
    Rep Power
    6

    Default

    and if it can't find javac... use
    Java Code:
    "path/javac"
    , including the ""
    I die a little on the inside...
    Every time I get shot.

Posting Permissions

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