Advertisement
veronikaaa86

06. Salary

Jun 27th, 2021
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. package forLoops;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06Salary {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int countTabs = Integer.parseInt(scanner.nextLine());
  10. int salary = Integer.parseInt(scanner.nextLine());
  11.  
  12. for (int i = 1; i <= countTabs; i++) {
  13. String websiteName = scanner.nextLine();
  14.  
  15. switch (websiteName){
  16. case "Facebook":
  17. salary -= 150;
  18. break;
  19. case "Instagram":
  20. salary = salary - 100;
  21. break;
  22. case "Reddit":
  23. salary = salary - 50;
  24. break;
  25. }
  26.  
  27. if (salary <= 0){
  28. break;
  29. }
  30. }
  31.  
  32.  
  33. if (salary <= 0){
  34. System.out.println("You have lost your salary.");
  35. } else {
  36. System.out.println(salary);
  37. }
  38. }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement