URI-1048-no-solution in c++

URI Online Judge Solution | 1048 || Salary Increase

Problem No:1048
Problem Level:Beginner
Online Judge:URI
Problem Link:https://www.urionlinejudge.com.br/judge/en/problems/view/1048
URI 1048



Solution in C++:

Source Code: 
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char const *argv[]) {
  float salary,total_salary,money;
  std::cin >> salary;
  if (salary>=0&&salary<=400.00) {
    money=(salary*15)/100;
    total_salary=salary+money;
    std::cout << "Novo salario: "<<fixed<<showpoint<<setprecision(2)<<total_salary << '\n';
    std::cout << "Reajuste ganho: "<<fixed<<showpoint<<setprecision(2)<<money << '\n';
    std::cout << "Em percentual: 15 %" << '\n';
  }else
  if (salary>=400.01&& salary<=800) {
     money=(salary*12)/100;
     total_salary=salary+money;
     std::cout << "Novo salario: "<<fixed<<showpoint<<setprecision(2)<<total_salary << '\n';
     std::cout << "Reajuste ganho: "<<fixed<<showpoint<<setprecision(2)<<money << '\n';
     std::cout << "Em percentual: 12 %" << '\n';
  }else
  if (salary>=800.01&&salary<=1200.00) {
     money=(salary*10)/100;
     total_salary=salary+money;
     std::cout << "Novo salario: "<<fixed<<showpoint<<setprecision(2)<<total_salary << '\n';
     std::cout << "Reajuste ganho: "<<fixed<<showpoint<<setprecision(2)<<money << '\n';
     std::cout << "Em percentual: 10 %" << '\n';

  }else
  if (salary>=1200.01&&salary<=2000.00) {
    money=(salary*7)/100;
    total_salary=salary+money;
    std::cout << "Novo salario: "<<fixed<<showpoint<<setprecision(2)<<total_salary << '\n';
    std::cout << "Reajuste ganho: "<<fixed<<showpoint<<setprecision(2)<<money << '\n';
    std::cout << "Em percentual: 7 %" << '\n';

  }else
  if(salary>2000.00){
    money=(salary*4)/100;
    total_salary=salary+money;
    std::cout << "Novo salario: "<<fixed<<showpoint<<setprecision(2)<<total_salary << '\n';
    std::cout << "Reajuste ganho: "<<fixed<<showpoint<<setprecision(2)<<money << '\n';
    std::cout << "Em percentual: 4 %" << '\n';
  }
  return 0;
}

Explanation:
It's a simple problem.You just have to count the total salary,and the benefit he can make.The you have to print those values according to the problem's statement.And don't forget to add the header file "iomanip" unless your compiler won't recognize setprecision(),showpoint,fixed etc.






























No comments

Powered by Blogger.