Temperature table fahrenheit celcius - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Temperature table fahrenheit celcius

mrbrightsidemrbrightside Posts: 2Member
I'm beginner on Java and right of the bat I was asked to right the following code: I'm still studying and trying to develop but I have spend a whole week and I still don't think I'm doing this correctly. Please help me, I'm stuck;

Heres the requirement and below is my code:

I need to Create a program that takes three inputs from the command line arguments. The inputs will need to be a starting and ending temperature and a step to increment by. For example, if the inputs were 1 5 1 the program would print a table with Fahrenheit temperatures (and their Celsius equivalent) for the temperatures 1, 2, 3, 4, 5. If the inputs were 2 10 2 the Farenheit temperatures would be: 2, 4, 6, 8, 10.
The program will convert temperatures from Fahrenheit to Celsius. The program will start at the starting temperature that was entered as a command line argument. Then the program will loop through all the Farenheit temperatures (incrementing by step on each loop iteration) until the program reaches the ending temperature that was specified as the second command line argument.
Your program should print out a Header line and then print out the Farenheit temperature and the corresponding Celsuis temperature on one line. For example:
Farenheit Celsius
212.0 100.0
The Farenheit temperature in your calculation can be an integer data type, but the Celsius temperature will need to be a floating point data type to ensure that the decimal digits are accurate.

package temperature.table;

public class TemperatureTable {

* @param args the command line arguments
public static void main(String[] args) {
// TODO code application logic here
int far, cel;
int lower, upper, step;
lower = 0;
upper = 200;
step = 15;
far = lower;

//somehow the print out is coming out incorrect

System.out.print("Fahrenheit Celsius");

while ( far <= upper )
cel = 5 * (far -32) /9;

System.out.println (" ");

System.out.println (cel);
far = far + step;
Sign In or Register to comment.