NAMA: NADYA MERDEKA WATI NPM: 1715061010 PEMROGRAMAN BERORIENTASI OBJEK (PBO)
10. Write a program that does the reverse of Exercise 9, that is, input degrees Fahrenheit and prints out the temperature in degrees Celsius. The formula to convert degrees Fahrenheit to equivalent degrees Celsius is
ANSWER 1. Source code package tugas; import java.util.*; public class Tugas { public static void main(String[] args) { Scanner suhu = new Scanner(System.in); double fahrenheit,celcius;
System.out.print("Enter the temperature in Fahrenheit: "); fahrenheit = suhu.nextDouble();
celcius = (fahrenheit-32)*5/9; System.out.print(fahrenheit + " " + "degrees Fahrenheit is equivalent with " + celcius + " " + "degrees Fahrenheit"); suhu.close(); } }
SCREENSHOOT Source Code
Output program