3 Replies - 37943 Views - Last Post: 20 September 2008 - 09:15 AM Rate Topic: ***-- 1 Votes

#1 circuspeanuts  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 224
  • Joined: 11-April 08

conversion from fahrenheit to celsius

Posted 20 September 2008 - 08:30 AM

ok so here's my code

temperature.java
import javax.swing.*;
public class Temperature {

	private
			String UserTemp;
			
			void SetTemperatureF() 
			{
				JOptionPane.showInputDialog("Please enter the temperature in fahrenheit");
				double fahrenheit = Double.parseDouble(UserTemp);
				double celsius = (5.0/9.0) * (fahrenheit - 32);
			}
			void convert(double ccelsius)
			{
				double fahrenheit =  ccelsius;  
				celsius = ccelsius;
			}
		   
			double GetTemperatureF(double ccelsius, double celsius)
			{
				ccelsius = celsius;
			   JOptionPane.showMessageDialog(null, "The degrees in celsius is " + celsius);				
			}
}




main.java
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		
		double ccelsius;
		
		Temperature oTemperature;
		oTemperature = new Temperature();
		oTemperature.SetTemperatureF();
		oTemperature.convert(ccelsius);
		oTemperature.GetTemperatureF(ccelsius);		
	}

}


this is really frustrating me. I can't seem to get it to allow me to send 2 variables over and my set function displays on the screen, but my get function doesn't seem to be working...any help please?

Is This A Good Question/Topic? 0
  • +

Replies To: conversion from fahrenheit to celsius

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2687
  • View blog
  • Posts: 11,346
  • Joined: 20-September 08

Re: conversion from fahrenheit to celsius

Posted 20 September 2008 - 08:35 AM

You need to store the temperature in setTemperatureF (correct spelling of a method name), and you're not doing so

This post has been edited by g00se: 20 September 2008 - 08:37 AM

Was This Post Helpful? 1

#3 circuspeanuts  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 224
  • Joined: 11-April 08

Re: conversion from fahrenheit to celsius

Posted 20 September 2008 - 08:42 AM

isn't it storing the temperature in
 double fahrenheit
after it converts UserTemp into a number?


edit:

like this?

void setTemperatureF() 
   {
				JOptionPane.showInputDialog("Please enter the temperature in fahrenheit");
				double fahrenheit = Double.parseDouble(UserTemp);
				double iTempFahrenheit = fahrenheit; 
				double ccelsius = (5.0/9.0) * (iTempFahrenheit - 32);
			}



I get these errors now:

		at schuthtylerweek01.Temperature.setTemperatureF(Temperature.java:21)
		at schuthtylerweek01.Main.main(Main.java:23)


This post has been edited by circuspeanuts: 20 September 2008 - 08:47 AM

Was This Post Helpful? 0
  • +
  • -

#4 circuspeanuts  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 224
  • Joined: 11-April 08

Re: conversion from fahrenheit to celsius

Posted 20 September 2008 - 09:15 AM

SOLVED! Thanks! I figured it out :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1