View Single Post
Old Jun 9th, 2005, 8:54 AM   #1
shangnyun
Programmer
 
shangnyun's Avatar
 
Join Date: Jun 2005
Posts: 34
Rep Power: 0 shangnyun is on a distinguished road
Temperature Conversion Program - Help!

I am soooooo lost!

Here's the assignment: "Write a program that allows the user to convert either from degrees Celsius to Fahrenheit or from degrees Fahrenheit to Celsius. In a loop, prompt the user to enter a temperature (as an integer). In a nested loop, prompt the user to enter a letter for Celsius or Fahrenheit. Use a switch statement to analyze the user input and to request to reenter the letter (but not the temperature) in case of invalid input. Print the result of conversion as a double and prompt the user to choose to continue or to quit."

More details from the book assignment: "Write a program that allows the user to convert either from degrees Celsius to Fahrenheit or from degrees Fahrenheit to Celsius. Use the following formulas:

degreesC = 5(degreesF = 32)/9
degreesF = (9(degreesC)/5) + 32

Prompt the user to enter a temperature and either a 'C' (or 'c') for Celsius or an 'F' (or 'f') for Fahrenheit; allow either uppercase or lowercase, but if anything other than 'C', 'c', 'F', or 'f' is entered, print an error message and ask the user to reeneter a valid selection (uppercase or lowercase 'C' or 'F'). Convert the temperature to Fahrenheit if Celsius is entered, or to Celsius if Fahrenheit is entered, and then ask the user to press 'Q' or 'q' to quit or to press any other key to repeat the loop and perform another conversion."

import java.util.*;

public class TempConversion
{
    public static void main(String[] args)
    {
    	int degreesC, degreesF;
    	
    	System.out.println("=====TEMPERATURE CONVERSION=====");
    	System.out.println();
    	System.out.println("Please enter a whole number for");
    	System.out.println("conversion:");
    	
    	Scanner keyboard = new Scanner(System.in);
    	
    	
    	degreesC = keyboard.nextInt();
    	degreesF = keyboard.nextInt();
    }
}

This is how far I am. Not far at all, in other words. I desperately need help on this one

Thanks
shangnyun is offline   Reply With Quote