Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package S4_ForLoops;
- import java.util.Scanner;
- public class Salary {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int tabsCount = Integer.parseInt(scanner.nextLine());
- int salary = Integer.parseInt(scanner.nextLine());
- // check for tab name and reduce salary
- for (int i = 1; i <= tabsCount; i++) {
- String tabName = scanner.nextLine();
- switch (tabName) {
- case "Facebook":
- // salary = salary - 150;
- salary -= 150;
- break;
- case "Instagram":
- // salary = salary - 100;
- salary -= 100;
- break;
- case "Reddit":
- // salary = salary - 50;
- salary -= 50;
- break;
- }
- // check if salary is 0 or less
- if(salary <= 0) {
- System.out.printf("You have lost your salary.");
- break;
- }
- }
- // check if salary is greater than 0
- if(salary > 0) {
- System.out.printf("%d", salary);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement