-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTemperatures.java
More file actions
28 lines (27 loc) · 850 Bytes
/
Temperatures.java
File metadata and controls
28 lines (27 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* QUESTION FIVE
* program to convert temperatures
*/
import java.util.Scanner;
@FunctionalInterface
interface TempConversion{
abstract void celcius(double f);//MY CONVERSION ABSTRACT METHOD
}
public class Temperatures {
public static void main(String args[]) {
Scanner pad = new Scanner(System.in);
//IMPLEMENTING THE TempConversion ABSTRACT METHOD
TempConversion converter = (double f) -> {
System.out.print("\n " + f + " FahrenHeights ~ " +
((f - 32) / 1.8) + " degrees celcius.");
};
while(true){
try{
System.out.print("\n Enter Temp: ");
converter.celcius(pad.nextDouble());//CONVERT TEMPERATURE
}catch(Exception e){
break;
}
}
}
}