# Thread: need help with a for loop

1. Member
Join Date
Jul 2014
Posts
5
Rep Power
0

## need help with a for loop

taking a seminar on java. was asked to work on building a program that can convert fahrenheit to kelvin. Need to create a for loop that spits out the value of kelvin for every degree increase from 32 degrees fahrenheit to 100 degrees fahrenheit. totally stumped. any tutors out there can help guide?

2. ## Re: need help with a for loop

Originally Posted by staticprofessional
taking a seminar on java. was asked to work on building a program that can convert fahrenheit to kelvin. Need to create a for loop that spits out the value of kelvin for every degree increase from 32 degrees fahrenheit to 100 degrees fahrenheit. totally stumped. any tutors out there can help guide?
The code for the loop is simple:
Java Code:
```for (double fahrenheit= 32; fahrenheit <= 100; fahrenheit++)
// convert fahrenheit to celcius and print the result here ...```
kind regards,

Jos

3. ## Re: need help with a for loop

@OP: please don't send me a PM w.r.t. your question; post follow up replies in the forum and maybe somebody else can be of help too.

kind regards,

Jos

ps. this was the code you posted in your PM:
Java Code:
```public class Converter
{
public static void main(String[] args)
{
for (double fahrenheit= 32; fahrenheit <= 100; fahrenheit++)
double celsius = 5/9.0*(farenheit-32);
double kelvin = celsius + 273.16;
System.out.println("The Kelvin equivalent of " fahrenheit + " degrees Fahrenheit is:" + kelvin);
}
}```
Last edited by JosAH; 07-07-2014 at 09:41 AM.

4. Member
Join Date
Jul 2014
Posts
5
Rep Power
0

## Re: need help with a for loop

sorry about that. but yea, still struggling with it.

5. Just a guy
Join Date
Jun 2013
Location
Netherlands
Posts
5,114
Rep Power
9

## Re: need help with a for loop

Let me reformat that code, perhaps then you'll see it.

Java Code:
```public class Converter {

public static void main(String[] args) {

for (double fahrenheit= 32; fahrenheit <= 100; fahrenheit++)
double celsius = 5/9.0*(farenheit-32);

double kelvin = celsius + 273.16;
System.out.println("The Kelvin equivalent of " fahrenheit + " degrees Fahrenheit is:" + kelvin);
}
}```

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•