# Fahrenheit to Celsius Program problem with assigning values to double

Page 1 of 1

## 5 Replies - 1804 Views - Last Post: 03 June 2011 - 04:13 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=234456&amp;s=a82c03d425fdc28e779181e0d9e54557&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Sonicdeath

Reputation: 0
• Posts: 3
• Joined: 03-June 11

# Fahrenheit to Celsius Program problem with assigning values to double

Posted 03 June 2011 - 01:16 PM

I'm having a problem with assigning multiple values to a double to produce an output.

I have to assign the following values in celsius and convert to Fahrenheit:
Celsius Fahrenheit
40 convert
39 convert
32 convert
31 convert

Will I need to use a loop for this?

I hate asking for help because I'm really getting into Java but I am really stuck on this. Any direction would be
very much appreciated.

```package conversion;
import java.util.Scanner;
/**
*
* @author Darin
*/
public class ConversionProgram {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);
//variables
double celsius;
double fahrenheit;
double foot;
double meters;

//Select option

System.out.println("Select 1 for Temperature Conversion Table");
System.out.println("Select 2 for Measurement Conversion Table");

{

case 1: celsiusToFahrenheit();
}
break;

}

}
//convert celsius to fahrenheit

public static double celsiusToFahrenheit() {
double celsius = 0;
double fahrenheit;

fahrenheit = ( 9.0/5 ) * celsius + 32;

System.out.println("\tFahrenheit \t  Celcius\n");
System.out.println("\t   " + fahrenheit + "\t\t " + celsius +"\n");
return fahrenheit;
}

}
}

```

Is This A Good Question/Topic? 0

## Replies To: Fahrenheit to Celsius Program problem with assigning values to double

### #2 smohd

• Critical Section

Reputation: 1824
• Posts: 4,627
• Joined: 14-March 10

## Re: Fahrenheit to Celsius Program problem with assigning values to double

Posted 03 June 2011 - 01:43 PM

But here you set celsius to 0, which does`t give logic. You need to ask user to input value for celsius, is n`t it?

### #3 Sonicdeath

Reputation: 0
• Posts: 3
• Joined: 03-June 11

## Re: Fahrenheit to Celsius Program problem with assigning values to double

Posted 03 June 2011 - 02:10 PM

smohd, on 03 June 2011 - 01:43 PM, said:

But here you set celsius to 0, which does`t give logic. You need to ask user to input value for celsius, is n`t it?

When the user selects option 1 it is supposed to bring up the table data and perform the calculations on each of those values.
I don't think there is user input. I had it done that way with using input.nextDouble() but that was incorrect.
Sorry i may have worded it wrong, I assigned 0 b/c i'm stuck on it and just put it there for now. I'm not sure if I should use an array, really frustrated with it that I havent figured it out.

### #4 smohd

• Critical Section

Reputation: 1824
• Posts: 4,627
• Joined: 14-March 10

## Re: Fahrenheit to Celsius Program problem with assigning values to double

Posted 03 June 2011 - 02:20 PM

Then if you have your already value, use array and loop between them.

### #5 nick2price

• D.I.C Lover

Reputation: 565
• Posts: 2,826
• Joined: 23-November 07

## Re: Fahrenheit to Celsius Program problem with assigning values to double

Posted 03 June 2011 - 03:57 PM

As been said, your answer at the moment will always be 0. You have 2 options. Ask the user to input a celcius value (which would make most sense to do), or you could hardcode the values and just print out the results. Whether you need a loop for this second options depends on the approach you take. You can store them in individual variables, therefore no loop is required. Or as said, you can use an Array, and then it would make more sense to use a loop.

### #6 Sonicdeath

Reputation: 0
• Posts: 3
• Joined: 03-June 11

## Re: Fahrenheit to Celsius Program problem with assigning values to double

Posted 03 June 2011 - 04:13 PM

Thanks for the replies I appreciate the help.