Transformação entre as escalas térmicas Kelvin, Fahrenheit e Celcius

Publicado por Guilherme de Matos Battista (última atualização em 08/04/2010)

[ Hits: 8.936 ]

Homepage: http://www.orkut.com.br/Main#Profile.aspx?uid=6801309084919838906&pcy=3&t=0

Download Conversor.pas




Este programa faz a conversão entre as escalas de temperatura mais usadas atualmente. No total são seis possibilidades de conversão, escritas com comandos extremamente simples.

Faz uso de variáveis INTEGER com a opção Trunc (arredondamento) nas equações, para não dar erro caso os resultados tenham vírgula.

Bons estudos.

  



Esconder código-fonte

program conversor;
uses crt; 
var u,f,x: string;
var t,r: integer;

begin
    repeat
        writeln ('Digite a unidade de temperatura que você vai inserir e quer transformar, sendo K , C ou F.');
        
        readln (u);
        
        writeln ('Digite a unidade de temperatura para a qual você quer transformar, sendo K, C ou F.');
        
        readln (f);
        
        writeln ('Digite a temperatura.');
        
        readln (t);
            begin
                if u = ('c')
                then begin 
                    if f = ('k')
                    then
                    r:= t+273;
                    end;
                begin 
                    if f = ('f') then
                    r:=Trunc(((t/5)*9)+32);
                end;
                begin 
                if f = ('c') then
                    r:=t;
                end;
                if u = ('c') then
                writeln (t, ' graus Celcius, em ', f,'° é ', r);
            end;
            begin
                if u = ('k')
                then begin
                    if f = ('c') then
                    r:=t-273;
                end;
                begin 
                    if f = ('f') then
                    r:=Trunc(((t/5)*9)+32)-273;
                end;
                begin 
                    if f = ('k') then
                    r:=t;
                end;
                if u = ('k') then
                writeln (t, ' Kelvin, em ', f,'° é ', r);
            end;
            begin
            if u = ('f')
            then begin
               if f = ('c') then
               r:=Trunc((t-32)/9)*5;
            end;
            begin 
               if f = ('k') then
               r:=Trunc(((t-32)/9)*5)+273;
            end;
            begin 
               if f = ('f') then
               r:=t;
            end;
            if u = ('f') then
            writeln (t, ' Fahrenheit, em ', f,'° é ', r);
         end;
         readkey;
      writeln ('Deseja parar o programa? Caso queira, digite "s". Caso contrário, tecle enter.');
      readln (x);
      clrscr;
   until x = ('s');
end.

Scripts recomendados

soma de um intervalo

Criptografador(Conceito criptografia)Lazarus

Cronômetro feito no Lazarus(Delphi 7 para Linux)

somatório de uma matriz 7x5

Jogo Sudoku em Pascal


  

Comentários

Nenhum comentário foi encontrado.


Contribuir com comentário




Patrocínio

Site hospedado pelo provedor RedeHost.
Linux banner

Destaques

Artigos

Dicas

Tópicos

Top 10 do mês

Scripts