URI Online Judge Solution 1048 Salary Increase - Solution in C, C++, Java, Python and C#
URI Online Judge Solution 1048 Salary Increase | BeginnerURI Problem Link - https://www.urionlinejudge.com.br/judge/en/problems/view/1048
Problem Name: 1048 Salary Increase Solution
Problem Number : URI - 1048 Salary Increase Code
Online Judge : URI Online Judge Solution
Category: Beginner
Solution Language : C,C plus plus, java, python, c#(c sharp)
URI 1048 Salary Increase Code in C / URI 1048 solution in C:
#include<stdio.h> int main() { float n; scanf("%f", &n); if (n <= 400.0) printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 15 %%\n", n * 1.15, n * 0.15); else if (n <= 800.0) printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 12 %%\n", n * 1.12, n * 0.12); else if (n <= 1200.0) printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 10 %%\n", n * 1.10, n * 0.10); else if (n <= 2000.0) printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 7 %%\n", n * 1.07, n * 0.07); else printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 4 %%\n", n * 1.04, n * 0.04); return 0; }
URI 1048 Salary Increase Code in C++ / URI 1048 solution in CPP:
We can obviously use the same C code here but for C++ solution I've added some extra things and more smarter code..
#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; }
URI 1048 Salary Increase Code in java/ URI 1048 solution in Java:
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: %.2f\nReajuste ganho: %.2f\nEm percentual: 15 %%\n", n * 1.15, n * 0.15); else if (n <= 800.0) System.out.printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 12 %%\n", n * 1.12, n * 0.12); else if (n <= 1200.0) System.out.printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 10 %%\n", n * 1.10, n * 0.10); else if (n <= 2000.0) System.out.printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 7 %%\n", n * 1.07, n * 0.07); else System.out.printf("Novo salario: %.2f\nReajuste ganho: %.2f\nEm percentual: 4 %%\n", n * 1.04, n * 0.04); } }
URI 1048 Salary Increase Code in Python / URI 1048 solution in Python:
URI Solution 1048 Salary Increase Code / URI 1048 solution in C# (C Sharp):
Demonstration:
Just implement this in coding. Since having any problem just put a comment below. Thanks
Tags: URI Online Judge Solution, URI OJ Solution list, URI Problems Solution, URI solver, URI all problem solution list, URI 1048 Salary Increase code in C, URI 1048 code in C++, URI Area of a circle solution in C, URI solution, URI 1048 Salary Increase solution in C,URI 1048 solution in C++-CPP, URI 1048 solution in C# (C sharp),URI 1048 solution in Java,URI 1048 Salary Increase solution in Python,
No comments:
Post a Comment