Advertisement
Guest User

Untitled

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