Advertisement
Guest User

Untitled

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