Why gives error in this type of comparison / choice?

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
Author: Guilherme Nascimento, 2018-08-15

1 answers

For your program to work 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 perform escolha/caso you have to remember that this type of structure is like switch/case in other languages. You have to have a number or character defined to be able to carry out the case. Example case 105 ... case 200... (pre defines the numbers that can be those of access to the case) in the example you gave it is as if it were a comparison, if consumption is escolha/caso)

 0
Author: YODA, 2018-08-16 00:04:12