Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: What is wrong with my code?

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default What is wrong with my code?

    I'm trying to convert Fahrenheit to Celsius but there are errors but I don't know where is the mistakes.
    The error is the part that I had bold it.

    public class CelsiusConverterApp {

    public static void main(String[] args) {

    double Fahrenheit = 98.6;

    //calculate Fahenheit to celsius
    double Celsius = (5.0/9) * (Fahrenheit 32.0) ;


    System.out.println("Fahrenheit " + Fahrenheit + "is" + Celsius + "in Celsius");


    }
    }


  2. #2
    Junior Member
    Join Date
    Jun 2012
    Posts
    20
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default Re: What is wrong with my code?

    What error is it showing? Or is the output ,you did not expect,is coming?

  3. #3
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default Re: What is wrong with my code?

    CelsiusConverterApp.java:8: illegal character: \8211
    CelsiusConverterApp.java:8: not a statement
    CelsiusConverterApp.java:8: ';' expected

  4. #4
    Junior Member
    Join Date
    Jun 2012
    Posts
    20
    Thanks
    1
    Thanked 3 Times in 3 Posts

    Default Re: What is wrong with my code?

    While writing the "-" operator did u use the one on the numpad or the other one near the "0" ?
    Because, when i wrote the program in eclipse,it ran perfectly well.

  5. The Following User Says Thank You to Karthik Prabhu For This Useful Post:

    unleashed-my-freedom (July 3rd, 2012)

  6. #5
    Junior Member
    Join Date
    Jul 2012
    Posts
    10
    Thanks
    3
    Thanked 2 Times in 2 Posts

    Default Re: What is wrong with my code?

    i'm using a laptop so there is only one button for -.

  7. #6
    Member GoodbyeWorld's Avatar
    Join Date
    Jul 2012
    Location
    Hidden command post deep within the bowels of a hidden bunker somewhere under a nondescrip building
    Posts
    219
    My Mood
    Stressed
    Thanks
    26
    Thanked 37 Times in 37 Posts

    Smile Re: What is wrong with my code?

    Yes, Karthik Prabhu is right.

    Try this code:

       public class CelsiusConverterApp {
     
          public static void main(String[] args) {
     
             double Fahrenheit = 98.6;
     
          //calculate Fahenheit to celsius
             double Celsius = (5.0/9) * (Fahrenheit - 32.0) ;
     
     
             System.out.println("Fahrenheit " + Fahrenheit + " is" + Celsius + " in Celsius");
     
     
          }
       }

    I also added spaces so it looks nicer. And it compiles.

  8. The Following User Says Thank You to GoodbyeWorld For This Useful Post:

    unleashed-my-freedom (July 3rd, 2012)

Similar Threads

  1. what is wrong with my code? need help
    By balmung123 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 1st, 2012, 04:12 AM
  2. What's Wrong With My Code?
    By Nuggets in forum What's Wrong With My Code?
    Replies: 11
    Last Post: January 31st, 2012, 09:11 PM
  3. need help .. what is wrong with my code.
    By baig-sh in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 10th, 2011, 06:28 PM
  4. What's Wrong With My Code?
    By arunjib in forum What's Wrong With My Code?
    Replies: 18
    Last Post: May 7th, 2011, 08:47 PM
  5. What's wrong with my code
    By javapenguin in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 10th, 2010, 02:24 PM