exercise in visualg algorithm

Asked

Viewed 1,067 times

1

The cost to the consumer of a new car is the sum of the factory cost with the percentage of the distributor and the taxes, both applied to the factory cost. It is known that the percentages are the same as in the following table. Make a program that gets the car factory cost and show the cost to the consumer.

Custo de Fábrica        % do Distribuidor       % dos impostos  
Até R$ 12.000,00                5                   Isento 
Entre R$ 12.000,00              10                  15 
Acima de R$ 25.000,00           15                  20

My code:

algoritmo "Preço" 

custo_fab, perc_dist, val_dist, perc_imp, val_imp, preco: real 
inicio 
    escreva("Informe o Custo de fábrica: ") 
    leia(custo_fab) 
    se (custo_fab < 12000) entao
        perc_dist <- 5
        perc_imp <- 0 
    senao 
        se (custo_fab < 25000) entao 
            perc_dist <- 10 
            perc_imp <- 15 
        senao 
            perc_dist <- 15 
            perc_imp <- 20 
        fimse 
    fimse 
    val_dist <- custo_fab * perc_dist / 100 
    val_imp <- custo_fab * perc_imp / 100 
    preco <- custo_fab + val_dist + val_imp 
    escreval("Preço ao consumidor: ", preco) 
fimalgoritmo
  • 1

    Your question is at what point of the task? did you do something? gave error in the code?

  • is that I didn’t bother to look like I did there

  • Which part did you not understand? was some calculation/formula? it went wrong?

  • went wrong I guess

  • Your code seems to work fine, why do you think it went wrong? Which was the input and which was the output?

No answers

Browser other questions tagged

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