Advertisement
zrhans

abastecimento.f90

Mar 22nd, 2016
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program abastecimento
  2. character(len=10) :: combustivel
  3.    print*,''
  4.    print *, "Posto de Combustivel!"
  5.    write(*,100)
  6.    valor = 100.00 ! R$ 100,00
  7.    combustivel = "Diesel"
  8.    call abastecer(tanque, valor, combustivel)
  9.    
  10.     write(*,103)"Litros abastecidos? ", tanque
  11.     write(*,*)"Tipo de combustivel? [Comum/Premium/Diesel] ", combustivel
  12.     write(*,100)
  13.     write(*,101) valor
  14.     write(*,102)
  15.    
  16. 100 format(1x,60('-'))
  17. 102 format(1x,60('_'),/)
  18. 101 format(' Total a pagar:  R$ ',f7.2)
  19. 103 format(a20, f7.2)
  20.    
  21. end program abastecimento
  22.  
  23. !========================================
  24. subroutine abastecer(tanque, valor, tipo)
  25. !========================================
  26. character(len=10) :: tipo
  27.     tanque = valor / preco_litro(tipo)
  28. end subroutine
  29.  
  30. !============================
  31. function preco_litro(tipogas)
  32. !============================
  33. character(len=10) :: tipogas
  34.  
  35. if ( tipogas .eq. 'Comum')  then
  36.     preco_litro = 3.9
  37. endif
  38.  
  39. if ( tipogas .eq. 'Premium') then
  40.     preco_litro = 4.09
  41. endif
  42.  
  43. if ( tipogas .eq. 'Diesel') then
  44.    preco_litro = 3.33
  45. endif
  46.  
  47. end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement