For conditions like this, we use the following ...
Select all
if 1 = 2 then
(...)
elsif 1 = 3 then
(...)
elsif 1 = 4 then
(...)
elsif 1=5 then
(...)
elsif 1 = 1 then
(...)
else
nenhum igual
end if;
In your case, you put the following routine ... and avoids it to enter into Two IF's
Select all
var
a,r,t,w: real
inicio
// Seção de Comandos
escreva("Digite o salario: ")
leia(a)
se a <= 500 então
r:= a*(15/100)
escreval(" Seu salário reajustado em 15% é: ", r)
senao
se a > 500 e a <= 1000 então
t:= a*(10/100)
escreval(" Seu salário reajustado em 10% é: ", t)
senao
se a > 1000 então
w:= a*(5/100)
escreval(" Seu salário reajustado em 5% é: ", w)
fimse
fimse
fimse
However, in its routine still needs an adjustment ...
1. No need to use 3 variables, with a variable only it is possible to do what you want.
Select all
var
a,r: real
inicio
// Seção de Comandos
escreva("Digite o salario: ")
leia(a)
se a <= 500 então --Se for menor igual a 500, entre
a:= a*(15/100)
escreval(" Seu salário reajustado em 15% é: ", a)
senao --se não for menor igual a 500, entre aqui...
se a > 500 e a <= 1000 então --Se for maior que 500 e menor igual a 100, entre...
a:= a*(10/100)
escreval(" Seu salário reajustado em 10% é: ", a)
senao --senao for maior que 500 e menor igual a 100...
se a > 1000 -- então então ele é maior que 1000
a:= a*(5/100)
escreval(" Seu salário reajustado em 5% é: ", a)
fimse
fimse
fimse
I think that's it!