fork download
  1. public class Main {
  2. double fahrenheit;
  3.  
  4. public Main(double f) {
  5. fahrenheit = f;
  6. }
  7.  
  8. public double toCelsius() {
  9. return (fahrenheit - 32) * 5 / 9;
  10. }
  11.  
  12. public static void main(String[] args) {
  13. double f = 100.0; // قيمة ثابتة
  14.  
  15. Main converter = new Main(f);
  16. double celsius = converter.toCelsius();
  17.  
  18. System.out.println("Temperature in Fahrenheit: " + f);
  19. System.out.println("Temperature in Celsius: " + celsius);
  20. }
  21. }
Success #stdin #stdout 0.14s 55652KB
stdin
Standard input is empty
stdout
Temperature in Fahrenheit: 100.0
Temperature in Celsius: 37.77777777777778