Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Salary {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double salary = Double.parseDouble(scanner.nextLine());
- int t = Integer.parseInt(scanner.nextLine());
- String yOrN = scanner.nextLine();
- double sal = salary;
- double n = 0;
- double m = 0;
- double diff = 0;
- if (salary >= 5000) {
- System.out.println("Current salary: 5000.00");
- System.out.println("0 more years to max salary.");
- } else {
- for (int i = 1; i <= t; i++) {
- sal += sal * 0.06;
- if (yOrN.equalsIgnoreCase("Yes")) {
- sal -= sal * 0.01;
- } else if (yOrN.equalsIgnoreCase("No")) {
- sal=sal;
- }
- if (i%10==0) {
- sal += 200;
- }
- if (i%10==5) {
- sal += 100;
- }
- }
- if (sal<5000){
- System.out.printf("Current salary: %.2f\n", sal);
- }
- else {
- System.out.println("Current salary: 5000.00");
- }
- for (int i = t; i < 50; i++) {
- if (sal >= 5000) {
- n=i-t;
- break;
- } else {
- sal += sal * 0.06;
- if (yOrN.equalsIgnoreCase("Yes")) {
- if (i%10!=0||i%10!=0){
- sal -= sal * 0.01;}
- } else if (yOrN.equalsIgnoreCase("No")) {
- sal=sal;
- }
- if (i %10==0) {
- sal += 200;
- }
- if(i%10 == 5) {
- sal += 100;
- }
- }
- }
- System.out.printf("%.0f more years to max salary.", n);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement