SHARE
TWEET

Untitled

a guest Feb 17th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class SalaryExerciseTask7 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int openTabs = Integer.parseInt(scanner.nextLine());
  8.         double salary = Double.parseDouble(scanner.nextLine());
  9.  
  10.         boolean isSalaryLost = false;
  11.  
  12.         for (int i = 0; i < openTabs; i++) {
  13.             String siteName = scanner.nextLine();
  14.  
  15.             if ("Facebook".equals(siteName)) {
  16.                 salary -= 150;
  17.  
  18.             } else if ("Instagram".equals(siteName)) {
  19.                 salary -= 100;
  20.  
  21.             } else if ("Reddit".equals(siteName)) {
  22.                 salary -= 50;
  23.  
  24.             }
  25.             if (salary <= 0){
  26.                 isSalaryLost = true;
  27.                 break;
  28.             }
  29.         }
  30.         if (isSalaryLost){
  31.             System.out.println("You have lost your salary.");
  32.         } else {
  33.             System.out.printf("%.0f", salary);
  34.         }
  35.     }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top