Advertisement
aneliabogeva

Salary

Dec 13th, 2020
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 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.         Integer n = Integer.parseInt(scanner.nextLine());
  7.         Integer salary = Integer.parseInt(scanner.nextLine());
  8.  
  9.         for (int i = 1; i <= n; i++){
  10.             String site = scanner.nextLine();
  11.  
  12.             if("Facebook".equals(site)){
  13.                 salary -= 150;
  14.                 if (salary <= 0) {
  15.                     System.out.println("You have lost your salary.");
  16.                     break;
  17.                 }
  18.             }else {}
  19.             if("Instagram".equals(site)){
  20.                 salary -= 100;
  21.                 if (salary <= 0) {
  22.                     System.out.println("You have lost your salary.");
  23.                     break;
  24.                 }
  25.             }else {}
  26.             if("Reddit".equals(site)) {
  27.                 salary -= 50;
  28.                 if (salary <= 0) {
  29.                     System.out.println("You have lost your salary.");
  30.                     break;
  31.                 } else {}
  32.             }
  33.         }
  34.         if(salary > 0){
  35.             System.out.println(salary);
  36.         }
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement