Advertisement
GabrielHr00

05. Salary

Jun 4th, 2023
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.96 KB | None | 0 0
  1. package S4_FoorLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Salary {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int tabsCount = Integer.parseInt(scanner.nextLine());
  9.         int salary = Integer.parseInt(scanner.nextLine());
  10.  
  11.         for (int i = 1; i <= tabsCount; i++) {
  12.             String tabName = scanner.nextLine();
  13.  
  14.             switch (tabName) {
  15.                 case "Facebook":
  16.                     salary -= 150;
  17.                     break;
  18.                 case "Instagram":
  19.                     salary -= 100;
  20.                     break;
  21.                 case "Reddit":
  22.                     salary -= 50;
  23.                     break;
  24.             }
  25.  
  26.             if(salary <= 0) {
  27.                 System.out.println("You have lost your salary.");
  28.                 break;
  29.             }
  30.         }
  31.  
  32.         if (salary > 0) {
  33.             System.out.println(salary);
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement