Advertisement
desislava_topuzakova

Untitled

Jul 31st, 2024
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. package ProgramingBasicsSoftUni.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.  
  9. int n = Integer.parseInt(scanner.nextLine());
  10. int salary = Integer.parseInt(scanner.nextLine());
  11.  
  12. for (int i = 1; i <= n; i++){
  13.  
  14. String site = scanner.nextLine();
  15. if (site.equals("Facebook")) {
  16. salary -= 150;
  17. } else if (site.equals("Instagram")) {
  18. salary -= 100;
  19. } else if (site.equals("Reddit")) {
  20. salary -= 50;
  21. }
  22.  
  23. if (salary <= 0) {
  24. System.out.println("You have lost your salary.");
  25. break;
  26. }
  27.  
  28. } if (salary > 0){
  29. System.out.println(salary);
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement