Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. class TwiceAsHot
  2. def initialize(temp, isFarenheit)
  3. @temperature = temp;
  4. @isFarenheit = isFarenheit;
  5. self.getInfo();
  6. end
  7.  
  8. def calculateTwiceAsHot
  9. if (@isFarenheit) then
  10. centigrade = (@temperature - 32) * (5 / 9);
  11. else
  12. centigrade = @temperature;
  13. end
  14.  
  15. kelvin = centigrade + 287;
  16. kelvin *= 2;
  17. centigrade = kelvin - 287;
  18.  
  19. if (@isFarenheit) then
  20. newTemperature = (centigrade * (9 / 5)) + 32;
  21. else
  22. newTemperature = centigrade;
  23. end
  24.  
  25. puts "If the temperature were to be twice as hot it would be #{newTemperature} degrees #{@isFarenheit ? 'Farenheit' : 'Centigrade'}.";
  26. end
  27.  
  28. def getInfo
  29. puts "The temperature is #{@temperature} degrees #{@isFarenheit ? 'Farenheit' : 'Centigrade'}.";
  30. end
  31. end
  32.  
  33. hot = TwiceAsHot.new(32, false);
  34. hot.calculateTwiceAsHot();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement