TempMain.java
package pack_Conversion; import java.util.Scanner; public class TempMain { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); System.out.print("화씨 온도를 입력하세요 : "); int fahrenheit = scanner.nextInt(); TempCalc tempCalc = new TempCalc(fahrenheit); double celsius = tempCalc.Celsius(); System.out.printf("섭씨 온도는 %.1f도 입니다.", celsius); scanner.close(); } }
TempCalc.java
package pack_Conversion; public class TempCalc { int fahrenheit; public TempCalc(int fahrenheit) { this.fahrenheit = fahrenheit; } public double Celsius() { double celsius = (double)5/9 * (fahrenheit-32); return celsius; } }