Calculate percentage of a salary to define the bonus [closed]

1

I must calculate the bonus of a user according to his salary. The salary must be paid and according to the amount entered the bonus is calculated, which must be within one of these ranges:

  

salario >= 100 and salario <= 200 percentage 10%

     

salario > 200 and salario <= 300 percentage 20%

     

% co_of% 30%%

This is the code that I have:

  Console.WriteLine("Ingrese su salario:");      
     var tarifa = Convert.ToDouble(Console.ReadLine());
        double salario;
        double porcentaje;
        double bono;
        if (salario >=100 && salario <=200)
        {
            salario * porcentaje(10%)= bono;
        }
        if (salario >200 && salario <= 300)
        {
            salario* porcentaje(20%)=bono; 
        }
        if (salario >300)
        {
            salario* porcentaje(30%) = bono;
        }
        else
        else 

        Console.WriteLine("Salario : " + salario);
        Console.WriteLine("Porcentaje: " + porcentaje);
        Console.WriteLine("Bono:" + bono);
        Console.ReadKey();
    
asked by Liszt Cea 11.11.2017 в 04:25
source

1 answer

2

The programming logic seems to me to be fine, you just have to make some small adjustments to your code:

Console.WriteLine("Ingrese su salario:");
decimal salario = Convert.ToDecimal(Console.ReadLine());
decimal bono = 0;
int porcentaje = 0;

if (salario >= 100 && salario <= 200)
{
    bono = salario * (decimal).10;
    porcentaje = 10;
}
else if (salario > 200 && salario <= 300)
{
    bono = salario * (decimal).20;
    porcentaje = 20;
}
else if (salario > 300)
{
    bono = salario * (decimal).30;
    porcentaje = 30;
}

Console.WriteLine("Salario : " + salario);
Console.WriteLine("Porcentaje: " + porcentaje + "%");
Console.WriteLine("Bono:" + bono);
Console.ReadKey();

Remember that when doing the assignments before the = is the variable where your result will be housed, for example for this case, it is not possible to do this salario* porcentaje(20%)=bono; , it should be something like bono = salario * (decimal).20; .

    
answered by 11.11.2017 / 05:24
source