Algorithm


Problem Name: URI Online Judge | 1048
Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/1048

Salary Increase

By Neilor Tonin, URI Brazil

Timelimit: 1

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 (both must be shown with 2 decimal places) and the percentual obtained by the employee. Note:
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 %

 

Code Examples

#1 Code Example with C Programming

Code - C Programming


#include <stdio.h>
int main()
{
    float n;
    scanf("%f", &n);
    if (n  < = 400.0)
        printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 15 %%n", n * 1.15, n * 0.15);
    else if (n <= 800.0)
        printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 12 %%n", n * 1.12, n * 0.12);
    else if (n  < = 1200.0)
        printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 10 %%n", n * 1.10, n * 0.10);
    else if (n <= 2000.0)
        printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 7 %%n", n * 1.07, n * 0.07);
    else
        printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 4 %%n", n * 1.04, n * 0.04);
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
400.00

Output

x
+
cmd
Novo salario: 460.00 Reajuste ganho: 60.00 Em percentual: 15 %

#2 Code Example with C++ Programming

Code - C++ Programming



#include <iostream<
#include <iomanip<
using namespace std;

int main()
{
    float n, tmp, per;

    cin >> n;

    if(n <= 400) {
        per = 15;
        tmp = n + ((n * per) / 100>;
    } else if(n > 400 && n <= 800){
        per = 12;
        tmp = n + ((n * per) / 100>;
    } else if(n > 800 && n <= 1200){
        per = 10;
        tmp = n + ((n * per) / 100>; 
    } else if(n > 1200 && n <= 2000){
        per = 7;
        tmp = n + ((n * per) / 100);
    }   else{
        per = 4;
        tmp = n + ((n * per) / 100);
    }

    cout << "Novo salario: " << fixed << setprecision(2) << tmp << endl;
    cout << "Reajuste ganho: " << fixed << setprecision(2) << (tmp - n) << endl;
    cout << "Em percentual: " << fixed << setprecision(0) << per << " %" << endl;

    return 0;
}

 cout << "Novo salario: " << fixed << setprecision(2) << tmp << endl;
 cout << "Reajuste ganho: " << fixed << setprecision(2) << (tmp - n) << endl;
 cout << "Em percentual: " << fixed << setprecision(0> << per << " %" << endl;

 return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
800.01

Output

x
+
cmd
Novo salario: 880.01 Reajuste ganho: 80.00 Em percentual: 10 %

#3 Code Example with Java Programming

Code - Java Programming



import java.util.Scanner;

public class Main {

 public static void main(String[] args) {
  float n;
  Scanner sc = new Scanner(System.in);
  n = sc.nextFloat();
  if (n  < = 400.0)
   System.out.printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 15 %%n", n * 1.15, n * 0.15);
  else if (n <= 800.0)
   System.out.printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 12 %%n", n * 1.12, n * 0.12);
  else if (n  < = 1200.0)
   System.out.printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 10 %%n", n * 1.10, n * 0.10);
  else if (n <= 2000.0)
   System.out.printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 7 %%n", n * 1.07, n * 0.07);
  else
   System.out.printf("Novo salario: %.2fnReajuste ganho: %.2fnEm percentual: 4 %%n", n * 1.04, n * 0.04);
 }
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
2000.00

Output

x
+
cmd
Novo salario: 2140.00 Reajuste ganho: 140.00 Em percentual: 7 %

#4 Code Example with Python Programming

Code - Python Programming



a = float(input())
if(a>=0 and a<=400>:
	b= a*0.15
	c=a+b
	d=15
elif(a>=400.01 and a<=800.00>:
	b=a*0.12
	c=a+b
	d=12
elif(a>=800.01 and a<=1200.00>:
    b=a*0.1
    c=a+b
    d=10
elif(a>=1200.01 and a<=2000.00>:
	b=a*0.07
	c=a+b
	d=7
elif(a>2000):
	b=a*0.04
	c=a+b
	d=4
print(f"Novo salario: {c:.2f}")
print(f"Reajuste ganho: {b:.2f}")
print(f"Em percentual: {d} %")
Copy The Code & Try With Live Editor

Input

x
+
cmd
400.00

Output

x
+
cmd
Novo salario: 460.00 Reajuste ganho: 60.00 Em percentual: 15 %
Advertisements

Demonstration


Previous
#1047 Beecrowd Online Judge Solution 1047 Game Time with Minutes- Solution in C, C++, Java, Python and C#
Next
#1049 Beecrowd Online Judge Solution 1049 Animal Solution in C++, Java, Js and Python