Why do you give an error in this type of comparison / choice?

1
escreval("Digite o consumo")
   leia(consumo)
   escolha consumo
   caso <= 100
      escreval("Parabéns, voce e economico")
   caso >=101 e <200
      escreval("Cuidado com o consumo")
   caso >200
      escreval("Consumo execessivo")
   outrocaso
      escreval("Valor invalido")
   fimescolha
    
asked by anonymous 16.08.2018 / 00:07

1 answer

0

For your program to work out this way it has to be by conditional structure se :

escreval("Digite o consumo")
   leia(consumo)
   se consumo  <= 100 e consumo>=0 entao

      escreval("Parabéns, voce e economico")
   fimse
   se consumo>=101 e  consumo<200 entao
      escreval("Cuidado com o consumo")
   fimse
   se consumo >=200  entao
      escreval("Consumo execessivo")
   fimse
      se consumo <0 entao
      escreval("Valor invalido")
   fimse

If you choose to do escolha/caso you have to remember that this type of structure is like switch/case in other languages. You must have a number or character set to perform the case. Case example 105 ... case 200 ... (pre sets the numbers that may be the case access numbers) in the example you gave is like a comparison, if consumption is

16.08.2018 / 01:51