Advertisement
deyanivanov966

06. Salary

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