dev_geral:scheme:exercicio_5_-_converter_fahrenheit_para_celsius_e_kelvin
Converter Fahrenheit para Celsius e Kelvin
; Exercicio 5 - Converter Fahrenheit em Celsius e em Kelvin
; Exercício resolvido por: Rui Maia (deathseeker25@portugal-a-programar.org)
; Escrever em Scheme o procedimento converte-Fahrenheit com o parametro tf
; que representa uma temperatura em graus Fahrenheit e responde como se indica:
;
;> (converte Fahrenheit 14)
;Fahrenheit: 14
;Centigrados: -10
;Kelvin: 263.16
;
; O procedimento pedido cria uma variável local com a temperatura em graus Centígrados
; para ser aproveitada no cálculo da temperatura em graus Kelvin.
(define converte-Fahrenheit
(lambda (tf)
(display "Fahrenheit: ")
(display tf)
(newline)
(let ((centigrados (* (- tf 32) (/ 5 9)))
(kelvin (+ (* (- tf 32) (/ 5 9)) 273.16)))
(display "Centigrados: ")
(display centigrados)
(newline)
(display "Kelvin: ")
(display kelvin))))
;> (converte-Fahrenheit 136)
;Fahrenheit: 136
;Centigrados: 520/9
;Kelvin: 330.9377777777778
dev_geral/scheme/exercicio_5_-_converter_fahrenheit_para_celsius_e_kelvin.txt · Última modificação em: 2018/05/14 21:37 (edição externa)