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 5 of 5

Thread: Farenheit 2 Celcius Converter output box problem (First Post)

  1. #1
    Junior Member
    Join Date
    Sep 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Farenheit 2 Celcius Converter output box problem (First Post)

    Hi all,

    I am working on a project for class and I've been tinkering with my code, but I can't seem to solve my error. I am not asking for someone to do my code, but I'm just hoping for a little nudge in the right direction. Any help would be appreciated. I have a couple of hours to knock this out.

    The assignment reads: Develop a Java program (F2C.java) for converting a temperature from the Fahrenheit to the Celsius scale. The program will read the temperature graphically using an input dialog box (JOptionPane.showInputDialog) and will show also the result graphically on a message dialog box (JOptionPane.showMessageDialog).

    I can get my input box to show, but I am unable to get to the output box

    What I have came up with:

    /*

    */


    import javax.swing.JOptionPane;

    public class F2C {
    public static void main(String[] args) {
    // Enter Farenheit
    String Fahrenheit = JOptionPane.showInputDialog(
    "Enter temperature in Fahrenheit:");

    //Process
    temperature = (temperature-32) * (5f/9);


    // Display results
    String output = "nTemperature in Celcius" + String.format("%.2f",temperature);
    JOptionPane.showMessageDialog(null, output);
    }
    }


  2. #2
    Junior Member
    Join Date
    Sep 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Farenheit 2 Celcius Converter output box problem (First Post)

    I am still a novice myself but I cleaned up what you had a little:

    */
    package temperature;

    import javax.swing.JOptionPane;

    public class F2C {
    public static void main(String[] args) {
    double temperature;
    // Enter Farenheit
    temperature = Double.parseDouble(JOptionPane.showInputDialog(
    "Enter temperature in Fahrenheit:"));

    // Process
    temperature = (temperature-32) * (5.0/9);


    // Display results
    String output = ("Temperature in Celcius is " + temperature);
    JOptionPane.showMessageDialog(null, output);
    }
    }

  3. #3
    Junior Member
    Join Date
    Sep 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Farenheit 2 Celcius Converter output box problem (First Post)

    AWESOME, Thanks! I watch a few videos and couldn't figure out where I went wrong... You saved my rear.

  4. #4
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Farenheit 2 Celcius Converter output box problem (First Post)

    madgame618, thanks for helping other users,but don't post ready made code. You know, teach how to fish instead of handing out fish.
    And use code tags when posting code.

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Farenheit 2 Celcius Converter output box problem (First Post)

    @madgame618: please review The Problem with Spoon-Feeding.

    +@Stingray36:

    You're both welcome to the forum, but please post your code using code or highlight tags as explained near the top of this topic. Review the rest of the topic for info helpful to new members.

Similar Threads

  1. [SOLVED] Java runtime get result output from prompt problem with a larger output in type
    By kingwang98 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 14th, 2014, 08:52 AM
  2. Making an input dialog box appear after closing a combo box
    By Shenaniganizer in forum What's Wrong With My Code?
    Replies: 14
    Last Post: November 11th, 2012, 06:22 PM
  3. Java 3 JCombo Box Problem
    By kpat in forum AWT / Java Swing
    Replies: 0
    Last Post: March 21st, 2012, 05:08 AM
  4. Problem on displaying Celcius
    By Superteo1987 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 31st, 2011, 10:23 AM
  5. converter program, problem with action listener
    By robertson.basil in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 2nd, 2010, 05:44 AM