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

Thread: TemperatureConverter Return Problem

  1. #1
    Junior Member
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default TemperatureConverter Return Problem

    I seem to be getting a problem. Please tell me what is wrong with my code

    Main.java
    package temperatureconverter;
     
    public class Main {
     
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args) {
            // TODO code application logic here
            TemperatureConverter myTemp=new TemperatureConverter();
            myTemp.convertTemp(10,'C');
     
     
        }
     
    }


    TemperatureConverter.java--CLASS
    package temperatureconverter;
    import java.lang.Math;
     
    public class TemperatureConverter {
        //VARIABLES
        char C;
        char F;
     
     
        //METHODS
        public String convertTemp(int temperature, char convertTo){
            if(temperature>=0&convertTo==C){
              System.out.println((temperature - 32) * 5.0 / 9.0);
            }else{
              System.out.println((temperature * 9.0 / 5.0) + 32 );
     
                return   //<<<Problem HERE "mssing return value" WHAT SHOULD I PUT HERE, I WANT IT TO PRINT THE TEMPERATURE AFTER CONVERSION
              }
            }
     
     
    }


    I am trying to make a simple Temperature Converter


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: TemperatureConverter Return Problem

    I seem to be getting a problem. Please tell me what is wrong with my code
    What problem? Exception? Compile problem? Behavior problems? You need to be specific, and suggested reading:
    Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)
    Summary of Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

Similar Threads

  1. how to return value ..
    By gr8mind in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 11th, 2011, 05:27 AM
  2. return a day of the year
    By lipry in forum Java Theory & Questions
    Replies: 3
    Last Post: January 23rd, 2011, 05:10 PM
  3. Problem with Return Function
    By Tracy22 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 26th, 2010, 03:32 PM
  4. [SOLVED] Problem accessing specific data in an array and getting it to return properly
    By Universalsoldja in forum Collections and Generics
    Replies: 3
    Last Post: February 4th, 2010, 04:26 PM
  5. Error of missing return statement while implementing Array
    By MS_Dark in forum Collections and Generics
    Replies: 1
    Last Post: December 10th, 2008, 03:18 PM

Tags for this Thread