Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Salary {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int openTabs = Integer.parseInt(scanner.nextLine());
- int salary = Integer.parseInt(scanner.nextLine());
- int penalty = 0;
- for (int i = 1; i <= openTabs; i++) {
- String siteName = scanner.nextLine();
- if (siteName.equals("Facebook")) {
- penalty += 150;
- } else if (siteName.equals("Instagram")) {
- penalty += 100;
- } else if (siteName.equals("Reddit")) {
- penalty += 50;
- } else {
- penalty += 0;
- }
- if ((salary - penalty) <= 0) {
- System.out.println("You have lost your salary.");
- break;
- }
- }
- if ((salary - penalty) > 0) {
- System.out.println(salary - penalty);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement