Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Salary_deductions {
- public static void main(String[] args) {
- Scanner key = new Scanner(System.in);
- System.out.print("Enter salary: ");
- int salary = Integer.parseInt(key.nextLine());
- System.out.print("Enter tabs open: ");
- int n = Integer.parseInt(key.nextLine());
- for (int i = 0; i < n; i++) {
- if (salary <= 0) {
- break;
- }
- System.out.print("Name of tag: ");
- String tagName = key.nextLine();
- switch (tagName) {
- case "Facebook":
- salary -= 150;
- if (salary <= 0) {
- System.out.println("You have finished your salary!");
- continue;
- }
- break;
- case "Instagram":
- salary -= 100;
- if (salary <= 0) {
- System.out.println("You have finished your salary!");
- continue;
- }
- break;
- case "Reddit":
- salary -= 50;
- if (salary <= 0) {
- System.out.println("You have finished your salary!");
- continue;
- }
- break;
- }
- }
- salary = salary;
- System.out.println(salary);
- if (salary > 0) {
- System.out.printf("You have %d lv. salary!", salary);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement