Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program abastecimento
- character(len=10) :: combustivel
- print*,''
- print *, "Posto de Combustivel!"
- write(*,100)
- valor = 100.00 ! R$ 100,00
- combustivel = "Diesel"
- call abastecer(tanque, valor, combustivel)
- write(*,103)"Litros abastecidos? ", tanque
- write(*,*)"Tipo de combustivel? [Comum/Premium/Diesel] ", combustivel
- write(*,100)
- write(*,101) valor
- write(*,102)
- 100 format(1x,60('-'))
- 102 format(1x,60('_'),/)
- 101 format(' Total a pagar: R$ ',f7.2)
- 103 format(a20, f7.2)
- end program abastecimento
- !========================================
- subroutine abastecer(tanque, valor, tipo)
- !========================================
- character(len=10) :: tipo
- tanque = valor / preco_litro(tipo)
- end subroutine
- !============================
- function preco_litro(tipogas)
- !============================
- character(len=10) :: tipogas
- if ( tipogas .eq. 'Comum') then
- preco_litro = 3.9
- endif
- if ( tipogas .eq. 'Premium') then
- preco_litro = 4.09
- endif
- if ( tipogas .eq. 'Diesel') then
- preco_litro = 3.33
- endif
- end function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement