Advertisement
GabrielHr00

Salary

Nov 20th, 2022
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package S4_ForLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Salary {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8. int tabsCount = Integer.parseInt(scanner.nextLine());
  9. int salary = Integer.parseInt(scanner.nextLine());
  10.  
  11. // check for tab name and reduce salary
  12. for (int i = 1; i <= tabsCount; i++) {
  13. String tabName = scanner.nextLine();
  14.  
  15. switch (tabName) {
  16. case "Facebook":
  17. // salary = salary - 150;
  18. salary -= 150;
  19. break;
  20. case "Instagram":
  21. // salary = salary - 100;
  22. salary -= 100;
  23. break;
  24. case "Reddit":
  25. // salary = salary - 50;
  26. salary -= 50;
  27. break;
  28. }
  29.  
  30. // check if salary is 0 or less
  31. if(salary <= 0) {
  32. System.out.printf("You have lost your salary.");
  33. break;
  34. }
  35. }
  36.  
  37.  
  38. // check if salary is greater than 0
  39. if(salary > 0) {
  40. System.out.printf("%d", salary);
  41. }
  42.  
  43. }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement