To Top Page Up Page Down To Bottom Auto Scroll Stop Scroll

Ini blog buat catatan online aku aja, buat dibuka kalo lagi lupa sesuatu. Kalo lagi ada ide tulis, kalo lupa tinggal buka.

Jumat, 10 Agustus 2018

Contoh Program Konversi Suhu (Fortran)


       program konversiSuhu
       implicit none
       real a,b,c,r,k,f

100    print *, 'Masukan Nilai yang ingin dikonversikan'
       read *, a
200    print *, '1 = Celcius'
       print *, '2 = Reamur'
       print *, '3 = Kelvin'
       print *, '4 = Fahrenheit'
       print *, 'Masukan satuan suhu (1-4)'
       read *, b

       !Celcius   
       if(b==1) then
       r=a*4/5
       k=a+273
       f=(a*9/5)+32
       write (*,'("C =",f12.2)') a   
       write (*,'("R =",f12.2)') r
       write (*,'("K =",f12.2)') k
       write (*,'("F =",f12.2)') f
       print *, 'Program Selesai'
       print *, ''
     
       !Reamur     
       else if (b==2) then
       c=a*5/4
       k=(a*5/4)+273
       f=(a*9/4)+32
       write (*,'("R =",f12.2)') a
       write (*,'("C =",f12.2)') c
       write (*,'("K =",f12.2)') k
       write (*,'("F =",f12.2)') f
       print *, 'Program Selesai'
       print *, ''

       !Kelvin
       else if (b==3) then
       c=a-273
       r=(a-273)*4/5
       f=((a-273)*9/5)+32
       write (*,'("K =",f12.2)') a    
       write (*,'("C =",f12.2)') c
       write (*,'("R =",f12.2)') r
       write (*,'("F =",f12.2)') f
       print *, 'Program Selesai'
       print *, ''

       !Fahrenheit
       else if (b==4) then
       c=(a-32)*5/9
       r=(a-32)*4/9
       k=((a-32)*5/9)+32
       write (*,'("F =",f12.2)') a   
       write (*,'("C =",f12.2)') c
       write (*,'("R =",f12.2)') r
       write (*,'("K =",f12.2)') k
       print *, 'Program Selesai'
       print *, ''   
      
       !else
       else
       print *, 'Maaf, mohon masukan angka 1 sampai 4'
       goto 200
  
       !end if
       endif
       goto 100
       end

Share:

0 komentar:

Posting Komentar

BTemplates.com

Cari Blog Ini

Diberdayakan oleh Blogger.

Kontributor