2
My code should have 4 validations and I’m using if
and else if
, but he’s only doing two of them, see the code below:
double salario = 0;
double p0 = 1.20;
double p1 = 1.15;
double p2 = 1.10;
double p3 = 1.05;
Console.WriteLine("Digite o valor do salário do funcionário: ");
salario = double.Parse(Console.ReadLine());
if (salario == 280) {
salario = (salario * p0);
Console.WriteLine("O salário do funcionário é: " + salario);
Console.WriteLine("O percentual de aumento aplicado foi: " + p0);
}
else if (salario >= 280 || salario <= 700)
{
salario = (salario * p1);
Console.WriteLine("O salário do funcionário é: " + salario);
Console.WriteLine("O percentual de aumento aplicado foi: " + p1);
}
else if (salario >= 700 || salario <= 1500)
{
salario = (salario * p2);
Console.WriteLine("O salário do funcionário é: " + salario);
Console.WriteLine("O percentual de aumento aplicado foi: " + p2);
}
else
{
salario = (salario * p3);
Console.WriteLine("O salário do funcionário é: " + salario);
Console.WriteLine("O percentual de aumento aplicado foi: " + p3);
}
Console.WriteLine("Pressione ENTER para sair...");
Console.Read();
When I put a salary amount that should go into the second else if
which refers to more than 700 and less than 1500 it does not with 1.10% it does as being 1.15% and I did a test for it to go to last condition and also will not, it always catch 1.15%.
The statement of the question is this:
The Tabajara Organizations decided to give a salary increase to their employees and hired them to develop the program that will calculate the adjustments. Prepare a routine that receives the salary of a collaborator and the adjustment according to the following criterion, based on the current salary: (1,0 point)
a. Salários até R$ 280,00 (incluindo): aumento de 20%; b. Salários entre R$ 280,00 e R$ 700,00: aumento de 15%; c. Salários entre R$ 700,00 e R$ 1500,00: aumento de 10%; d. Salários de R$ 1500,00 em diante: aumento de 5%.
After the increase is performed, inform on the screen:
a. O salário antes do reajuste; b. O percentual de aumento aplicado; c. O valor do aumento; d. O novo salário, após o aumento.
Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful for you. You can also vote on any question or answer you find useful on the entire site (when you have 15 points, you will have it right after you accept it).
– Maniero