Java program to convert degree from centrigrade to fahrenheit

Program that displays a table of centrigrade temp 0 though 20 and their fahrnheit.  Program use a loop to display the table.

Problem, the program compiles with no errors. when I enter the degrees in centrigrade they convert and display in the fahrenheit field, however, when I enter the second degree, it appears on the same line as the previous. Not sure whether I am explaining this clearly.  If someone would compile the program, you'll see what I am talking about.

Thank you in advance for your assistance.
import java.util.Scanner; 
import javax.swing.JOptionPane;
public class CentrigradeGay
	public static void main (String[] args)
		final int BASE = 32; 
		final double CONVERSION_FACTOR = 9.0 / 5.0; 
		final int MIN_DEGREE = 0;
		final int MAX_DEGREE = 20;
		int degree;
		int number = 1;
		String input;
		Scanner keyboard = new Scanner(; 
		System.out.print("No more than 20 entries may be entered.");
		degree = keyboard.nextInt();
		if (degree > 0 && degree <= 20)	
			System.out.println("Please enter temperature" );
			System.out.println("Entries must be in the range of 0 and 20, please re-enter: ");
			degree = keyboard.nextInt();
			for (number = 1; number > 0 && number <= 20; number++)
					double centrigradeTemp; 
					centrigradeTemp = keyboard.nextDouble(); //read in user input
					double fahrenheitTemp;
					fahrenheitTemp = centrigradeTemp * CONVERSION_FACTOR + BASE; //calculate Fahrenheit temperature
						System.out.print("\t\t" + fahrenheitTemp);

Open in new window

Who is Participating?
Ajay-SinghConnect With a Mentor Commented:
change this
 >> System.out.print("\t\t" + fahrenheitTemp);


System.out.println("\t\t" + fahrenheitTemp);
hrattanConnect With a Mentor Commented:
try adding a \n

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.