Good afternoon guys, all right?
I have an Algorithm I exercise, and I'm stuck in a doubt. The question:
- Write a procedure that receives an integer and prints it in the extended form. For example, for 1 the desired output is "One." The function must be able to generate the length of numbers from 1 to 15 inclusive. If an unsupported number is received the procedure should display an error message. Also create an algorithm that reads an integer value and call the procedure created above for printing the extended number.
My code:
algoritmo "APS09"
var
num: inteiro
procedimento FormaExtensa(n:inteiro)
var
extenso:caracter
inicio
escolha n
caso "1"
extenso <- "Um"
caso "2"
extenso <- "Dois"
caso "3"
extenso <- "Três"
caso "4"
extenso <- "Quatro"
caso "5"
extenso <- "Cinco"
caso "6"
extenso <- "Seis"
caso "7"
extenso <- "Sete"
caso "8"
extenso <- "Oito"
caso "9"
extenso <- "Nove"
caso "10"
extenso <- "Dez"
caso "11"
extenso <- "Onze"
caso "12"
extenso <- "Doze"
caso "13"
extenso <- "Treze"
caso "14"
extenso <- "Quatorze"
caso "15"
extenso <- "Quinze"
outrocaso
extenso <- "Número não compatível"
fimescolha
escreval(extenso)
fimprocedimento
inicio
escreva("Digite um número até 15: ")
leia(num)
FormaExtensa(num)
fimalgoritmo
However, at the time of running, it asks to type the correct number, however, any number that I type, it gives an error in caso "1"
and says that I expected an INTEGER. I still do not understand where he expected an integer value.
Can anyone help me with this? Thank you in advance.
[RESOLUTION]
I just removed the quotation marks from the case, as suggested in response to the post.
caso 1
extenso <- "Um"
caso 2
extenso <- "Dois"
caso 3
extenso <- "Três"
caso 4
extenso <- "Quatro"
caso 5
extenso <- "Cinco"
caso 6
extenso <- "Seis"
caso 7
extenso <- "Sete"
caso 8
extenso <- "Oito"
caso 9
extenso <- "Nove"
caso 10
extenso <- "Dez"
caso 11
extenso <- "Onze"
caso 12
extenso <- "Doze"
caso 13
extenso <- "Treze"
caso 14
extenso <- "Quatorze"
caso 15
extenso <- "Quinze"
outrocaso
extenso <- "Número não compatível"
fimescolha