Advertisement
Kancho

Salary_Deductions

Feb 13th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Salary_deductions {
  4. public static void main(String[] args) {
  5.  
  6. Scanner key = new Scanner(System.in);
  7. System.out.print("Enter salary: ");
  8. int salary = Integer.parseInt(key.nextLine());
  9. System.out.print("Enter tabs open: ");
  10. int n = Integer.parseInt(key.nextLine());
  11.  
  12. for (int i = 0; i < n; i++) {
  13. if (salary <= 0) {
  14. break;
  15. }
  16. System.out.print("Name of tag: ");
  17. String tagName = key.nextLine();
  18.  
  19. switch (tagName) {
  20. case "Facebook":
  21. salary -= 150;
  22. if (salary <= 0) {
  23. System.out.println("You have finished your salary!");
  24. continue;
  25. }
  26. break;
  27.  
  28. case "Instagram":
  29.  
  30. salary -= 100;
  31. if (salary <= 0) {
  32. System.out.println("You have finished your salary!");
  33. continue;
  34. }
  35. break;
  36.  
  37. case "Reddit":
  38.  
  39. salary -= 50;
  40. if (salary <= 0) {
  41. System.out.println("You have finished your salary!");
  42. continue;
  43. }
  44.  
  45. break;
  46.  
  47. }
  48.  
  49. }
  50.  
  51. salary = salary;
  52. System.out.println(salary);
  53. if (salary > 0) {
  54. System.out.printf("You have %d lv. salary!", salary);
  55.  
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement