Add calling method named Centrigrade to the program

gkilgore
gkilgore used Ask the Experts™
on
Use the formula to convet fahrenheit to centrigrade.  Write a method named Centrigrade that accepts Fahrenheit temperature as a argument.  Method should return temperature converted to Centigrade.  Demonstrate the method by calling it in a loop that displays a table of Fahrenheit 0 through 20.  My program displays the requirements, however, after 20 iterations have been made the program starts over.  Also, Not sure where to add the calling method named centrigrade(); in my main program.
import java.util.Scanner; 
import javax.swing.JOptionPane;
import java.io.*;
 
 
public class CentrigradeToFahrenheitTest
{
	public static void main(String[] args)
	{
	 	int number = 1;
		int degree;
    	boolean done=false;
    	    	String type = null; 
					String input;
 
//Create a Scanner object for keyboard input.				
		DataInput keyboard = new DataInputStream(System.in);
 
//Select F to convert to C.		
		do
		
		{
    		System.out.println("Press F to convert F-C");
    		try
			{
    			type = keyboard.readLine();
    		}
				catch(Exception e)
				{
    				System.out.println(e);
    			}
    		if(type.equals("F") || type.equals("f"))
			{
			
//Enter temperature to be converted.			
    			System.out.println("Please input the temprature: ");
				
				System.out.println("Fahrenheit\t\tCentrigrade");
				System.out.println("============================");
			
		  		try
				{
					for (number = 1; number > 0 && number <= 20; number++)
				
	    				Centrigrade(Double.valueOf(keyboard.readLine()).doubleValue());
				}
					catch(Exception e)
					{
    					System.out.println(e);
    				}
				
    		}
			
		}	
			while(!done);
	}
 
	public static void Centrigrade(double temp)
	{
	 			System.out.print(temp);
				temp = (temp - 32) / 1.8;
				System.out.println("\t\t" + temp);
		}}

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Java Developer
Top Expert 2010
Commented:
just remove that do loop

Author

Commented:
Perfect.  Thank you very much!!!!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial