Advertisement
Vladkoheca

Salary.java

Oct 13th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 KB | Source Code | 0 0
  1. import java.util.Scanner;
  2. public class Main {
  3.     public static void main(String[] args) {
  4.         Scanner petio = new Scanner(System.in);
  5.         int tabs = petio.nextInt();
  6.         int salary = petio.nextInt();
  7.         for (int i = tabs; i >= 0; i--) {
  8.             String da = petio.nextLine();
  9.             if (da.equals("Facebook")) {
  10.                 salary -= 150;
  11.             } else if (da.equals("Instagram")) {
  12.                 salary -= 100;
  13.             } else if (da.equals("Reddit")) {
  14.                 salary -= 50;
  15.             }
  16.             if (salary == 0 ) {
  17.                 break;
  18.             }
  19.  
  20.         }
  21.         if (salary == 0 ) {
  22.             System.out.println("you have lost your salary.");
  23.         }
  24.         else {
  25.             System.out.println(salary);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement