grach

Salary_January-2020

Mar 6th, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Salary {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         int n = Integer.parseInt(scan.nextLine());
  8.         double salary = Double.parseDouble(scan.nextLine());
  9.  
  10.         //String a = "Facebook";
  11.         //String b = "Instagram";
  12.         //String c = "Reddit";
  13.  
  14.         for (int i = 1; i <=n ; i++) {
  15.             String name = scan.nextLine();
  16.  
  17.             if (name.equals("Facebook")) {
  18.                 salary = salary - 150;
  19.             }
  20.             if (name.equals("Instagram")) {
  21.                 salary = salary - 100;
  22.             }
  23.             if (name.equals("Reddit")) {
  24.                 salary = salary - 50;
  25.             }
  26.             if (salary<=0){
  27.                 System.out.println("You have lost your salary.");
  28.             return;} // с return излизам от кода
  29.  
  30.         }
  31.         System.out.printf("%.0f",salary);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment