Difference between revisions of "Temperature Calculator"

From CompSciWiki
Jump to: navigation, search
 
Line 1: Line 1:
 
{{1010PrAD
 
{{1010PrAD
  
|ProblemName=Hello World
+
|ProblemName=Temperature Calculator
 +
 
 +
|Problem=Write a Java program Temp, that converts celcius to fahrenheit or vice versa.<br/>The program should:
 +
*prompt the user for a 1-character string c (celcius) or f (fahrenheit) that tells the program which unit you are entering
 +
*prompt the user for the temperature as an integer (2-digits max)
 +
*output the solution followed by a c or f to note the final unit
 +
<br/>
 +
Example: User inputs "c" and "10" would result in "50f"
 +
<br/>
 +
<br/>
 +
 
 +
Use the following formula to convert your units<br/>
 +
 
 +
F = 9C/5 + 32
  
|Problem=The problem
 
  
 
|SolutionCode=public class HelloWorld
 
|SolutionCode=public class HelloWorld

Revision as of 12:35, 1 April 2010

Back to the Program-A-Day homepage

Problem

Write a Java program Temp, that converts celcius to fahrenheit or vice versa.
The program should:

  • prompt the user for a 1-character string c (celcius) or f (fahrenheit) that tells the program which unit you are entering
  • prompt the user for the temperature as an integer (2-digits max)
  • output the solution followed by a c or f to note the final unit


Example: User inputs "c" and "10" would result in "50f"

Use the following formula to convert your units

F = 9C/5 + 32

 

...by students

float
Taken from http://www.flickr.com/photos/daniello/565304023/

An image or By Students section

Solution

The solution...

Code

Solution Code

Back to the Program-A-Day homepage