Advertisement
DanielDv99

TEMPERATURE_TEST

Sep 25th, 2017
2,692
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Eiffel 1.22 KB | None | 0 0
  1. note
  2.     description : "Temperature application root class"
  3.  
  4. class
  5.     APPLICATION
  6.  
  7. create
  8.     make
  9.  
  10. feature {NONE} -- Initialisation
  11.  
  12.     make
  13.             -- Run application.
  14.         local
  15.             temperature1 : TEMPERATURE
  16.             temperature2 : TEMPERATURE
  17.             input_value : INTEGER
  18.             average : TEMPERATURE
  19.         do
  20.             -- Input temperature in Celsius and show the converted value in Kelvin.
  21.             print("Enter the first temperature in Celsius: ")
  22.             IO.read_integer
  23.             input_value := IO.last_integer
  24.             create temperature1.make_celsius (input_value)
  25.             print("First temperature in Kelvin is: " + temperature1.kelvin.out)
  26.             IO.put_new_line
  27.  
  28.             -- Input temperature in Kelvin and show the converted value in Celsius.
  29.             print("Enter the second temperature in Kelvin: ")
  30.             IO.read_integer
  31.             input_value := IO.last_integer
  32.             create temperature2.make_kelvin (input_value)
  33.             print("Second temperature in Celsius is: " + temperature2.celsius.out)
  34.             IO.put_new_line
  35.  
  36.             -- Calculate the average temperature and show it in both Celsius and Kelvin.
  37.             average := temperature1.average (temperature2)
  38.             print("The average temperature in Celsius: " + average.celsius.out + "%N")
  39.             print("The average temperature in Kelvin: " + average.kelvin.out)
  40.  
  41.         end
  42.  
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement