URI Online Judge Solution 1048 Salary Increase using C Programming Language.
The company ABC decided to give a salary increase to its employees, according to the following table:
Salary | Readjustment Rate |
0 - 400.00
400.01 - 800.00 800.01 - 1200.00 1200.01 - 2000.00 Above 2000.00 |
15%
12% 10% 7% 4% |
Read the employee's salary, calculate and print the new employee's salary, as well the money earned and the increase percentual obtained by the employee, with corresponding messages in Portuguese, as the below example.
Input
The input contains only a floating-point number, with 2 digits after the decimal point.
Output
Print 3 messages followed by the corresponding numbers (see example) informing the new salary, the among of money earned and the percentual obtained by the employee. Note:
Novo salario: means "New Salary"
Reajuste ganho: means "Money earned"
Em percentual: means "In percentage"
Novo salario: means "New Salary"
Reajuste ganho: means "Money earned"
Em percentual: means "In percentage"
Input Sample | Output Sample |
400.00
|
Novo salario: 460.00
Reajuste ganho: 60.00 Em percentual: 15 % |
800.01
|
Novo salario: 880.01
Reajuste ganho: 80.00 Em percentual: 10 % |
2000.00
|
Novo salario: 2140.00
Reajuste ganho: 140.00 Em percentual: 7 % |
Solution using C :
#include <stdio.h>
int main() {
float sal,ans=0;
int p;
scanf("%f",&sal);
if(sal>=0 && sal <= 400.00)
{
p = 15;
ans = sal + (sal*p)/100;
}
else if(sal>=400.01 && sal <= 800.00)
{
p = 12;
ans = sal + (sal*p)/100;
}
else if(sal>=800.01 && sal <= 1200.00)
{
p = 10;
ans = sal + (sal*p)/100;
}
else if(sal>=1200.01 && sal <= 2000.00)
{
p = 7;
ans = sal + (sal*p)/100;
}
else if(sal>2000.01)
{
p = 4;
ans = sal + (sal*p)/100;
}
printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: %d %%\n",ans,ans-sal,p);
return 0;
}
Comments
Post a Comment