Advertisement
Spocoman

Annual Salary

Sep 1st, 2024
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int experience = Integer.parseInt((scanner.nextLine()));
  7.         String specialty = scanner.nextLine();
  8.         double salary = 0;
  9.         if (specialty.equals("C# Developer"))
  10.             salary = 5400;
  11.         else if (specialty.equals("Java Developer"))
  12.             salary = 5700;
  13.         else if (specialty.equals("Front-End Web Developer"))
  14.             salary = 4100;
  15.         else if (specialty.equals("UX / UI Designer"))
  16.             salary = 3100;
  17.         else if (specialty.equals("Game Designer"))
  18.             salary = 3600;
  19.  
  20.         if (experience <= 5)
  21.             salary -= salary * 0.658;
  22.  
  23.         System.out.printf("Total earned money: %.2f BGN", salary * 12);
  24.     }
  25. }
  26.  
  27. ИЛИ:
  28.  
  29. import java.util.Scanner;
  30.  
  31. public class Main {
  32.     public static void main(String[] args) {
  33.         Scanner scanner = new Scanner(System.in);
  34.         int experience = Integer.parseInt((scanner.nextLine()));
  35.         String specialty = scanner.nextLine();
  36.         double salary =
  37.                 switch (specialty) {
  38.                     case "C# Developer" -> 5400;
  39.                     case "Java Developer" -> 5700;
  40.                     case "Front-End Web Developer" -> 4100;
  41.                     case "UX / UI Designer" -> 3100;
  42.                     case "Game Designer" -> 3600;
  43.                     default -> 0;
  44.                 };
  45.  
  46.         if (experience <= 5)
  47.             salary -= salary * 0.658;
  48.  
  49.         System.out.printf("Total earned money: %.2f BGN", salary * 12);
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement