Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package LoopsExams;
- import java.util.Scanner;
- public class Salary {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double basicSalaryFirstYear = Double.parseDouble(scanner.nextLine());
- int totalYears = Integer.parseInt(scanner.nextLine());
- String syndicateMember = scanner.nextLine();
- double currentSalary = basicSalaryFirstYear;
- int counter = 0;
- double maxSalary = 5000.00;
- for (int i = 1; i <= 100; i++) {
- counter++;
- currentSalary = currentSalary + currentSalary * 0.06;
- if (counter % 10 == 5) {
- currentSalary += 100;
- }
- if (counter % 10 == 0) {
- currentSalary += 200;
- }
- if (syndicateMember.equals("Yes")) {
- if (counter % 10 != 0 && counter % 10 != 5) {
- currentSalary = currentSalary - currentSalary * 0.01;
- }
- }
- if (currentSalary >= maxSalary && i <= totalYears) {
- System.out.println("Current salary: 5000.00");
- System.out.println("0 more years to max salary.");
- return;
- }
- if (i == totalYears) {
- System.out.printf("Current salary: %.2f%n", currentSalary);
- }
- if (currentSalary >= maxSalary) {
- System.out.printf("%d more years to max salary.", i - 1 - totalYears);
- return;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment