Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f254f58

Browse files
Shows use of primitive data types and arithmetic
Computes the Fahrenheit equivalent of a specific Celsius value using the formula F = (9/5)C + 32.
1 parent 2e751e4 commit f254f58

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//********************************************************************
2+
// TempConverter.java Author: Lewis/Loftus
3+
//
4+
// Demonstrates the use of primitive data types and arithmetic
5+
// expressions.
6+
//********************************************************************
7+
public class TempConverter
8+
{
9+
//-----------------------------------------------------------------
10+
// Computes the Fahrenheit equivalent of a specific Celsius
11+
// value using the formula F = (9/5)C + 32.
12+
//-----------------------------------------------------------------
13+
public static void main(String[] args)
14+
{
15+
final int BASE = 32;
16+
final double CONVERSION_FACTOR = 9.0 / 5.0;
17+
double fahrenheitTemp;
18+
int celsiusTemp = 24; // value to convert
19+
fahrenheitTemp = celsiusTemp * CONVERSION_FACTOR + BASE;
20+
System.out.println("Celsius Temperature: " + celsiusTemp);
21+
System.out.println("Fahrenheit Equivalent: " + fahrenheitTemp);
22+
}
23+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /