AcWing 669. 加薪 - Java
原题链接
简单
作者:
KYCygni
,
2021-03-07 14:03:26
,
所有人可见
,
阅读 287
Java 代码
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner cin = new Scanner(System.in);
double s = cin.nextDouble();
double[] sr = {0, 400.01, 800.01, 1200.01, 2000.01};
int[] p = {15, 12, 10, 7, 4};
double inc = 0.0;
int incP = 0;
for (int i = sr.length-1; i >=0; i--)
{
if (s >= sr[i])
{
incP = p[i];
inc = s * incP / 100.0;
s += inc;
break;
}
}
System.out.println("Novo salario: " + String.format("%.2f", s));
System.out.println("Reajuste ganho: " + String.format("%.2f", inc));
System.out.println("Em percentual: " + incP + " %");
}
}