Save the ticket values by adding to the existing amount

0
  

Create a flowchart that reads the user's value of a ticket and at the end shows: the total of the collection and how many tickets were sold. The flowchart should only stop when entering zero in the value of the ticket.

It needs to store in the variables totval and totquant until you enter 0 in the value to finish and show the amount of tickets sold and the amount.

Var
// Seção de Declarações das variáveis 
val,quant,totval,totquant : real

Inicio
// Seção de Comandos, procedimento, funções, operadores, etc...
totval <- 0
totquant <- 0
repita

escreval("Qual valor do ingresso: ")
leia(val)
escreval("Quantos ingressos: ")
leia(quant)

totval <- val*quant
totquant <-quant


até val = 0
escreval ("valor total de ingressos é: ",totval)
escreval ("Quantidade de ingressos vendido é: " ,totquan
    
asked by anonymous 06.08.2018 / 21:09

1 answer

1

You need to make an accumulation and are discarding the previous value in each assignment in the variables. To accumulate you have to get the current value of the variable and add it to the new value you want to accumulate.

Var
    val, quant, totval, totquant : real
Inicio
    totval <- 0
    totquant <- 0
    repita
        escreval("Qual valor do ingresso: ")
        leia(val)
        escreval("Quantos ingressos: ")
        leia(quant)
        totval <- totval + val * quant
        totquant <- totquant + quant
    até val = 0
    escreval ("valor total de ingressos é: ",totval)
    escreval ("Quantidade de ingressos vendido é: " , totquan)
fim
    
06.08.2018 / 21:20