I calculate to buy fuel by value?

Asked

Viewed 439 times

1

I am doing a program of a fuel pump using classes, but I am not able to calculate the amount of fuel for the value inserted, someone can give a light?

class BombaCombustivel():

    def __init__(sel, tipoComb, valorLitro, quantComb):
        self.tipoComb = tipoComb
        self.valorLitro = valorLitro
        self.quantComb = quantComb

    def abastecerPorValor(self):
        abastecerV = float(input("Valor a ser abastecido: "))
        tirarComb = **calculo aqui**
        abastecido = "Combustivel colocado: %d L"% tirarComb
        return abastecerV

    def abastecerPorLitro(self):
        abastecerL = int(input("Quantidade de litros: "))
        if abastecerL.isdigit():
            pagar = self.valorLitro * self.abastecerL
            valorPagar = "Valor a ser pago: R$ %f"% pagar

    def setAlterarValor(self):

    def setAlterarCombustivel(self):

    def setAlterarQuantidadeCombustivel(self):

1 answer

3

Right, you need to know how many liters of fuel you should put with real X. How about dividing the amount of money by the price of fuel?

Considering that the price of the liter is 4 real and the driver wants to put 100 real, the quantity supplied should be 25 liters (100/4).

It is up to you to implement in the code this ;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.