Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ch03/CelsiusToFahrenheit.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import java.util.Scanner;

public class CelsiusToFahrenheit {

public static void main(String[] args) {
// Create variables
double celsius;
double fahrenheit;
final int FREEZING_TEMP = 32;
Scanner input = new Scanner(System.in);

// Ask for number in celsius, then save that input as the celsius variable
System.out.print("Enter a temperature in Celsius: ");
celsius = input.nextDouble();
System.out.printf("%.1f celsius\n", celsius);

// Conver celsius to fahrenheit
fahrenheit = (celsius * 9.0/5.0) + (FREEZING_TEMP);

// Display result!
System.out.printf("%.1f celsius = %.1f fahrenheit\n", celsius, fahrenheit);



}


}