marking2112

Dwarf Present 16 December 2017

Jul 3rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P17_Dwarf {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double dwarfNum = Integer.parseInt(scanner.nextLine());
  8.         double santaBudget = Integer.parseInt(scanner.nextLine());
  9.         String present = "";
  10.  
  11.         double sandClock = 2.20;
  12.         double magnet = 1.50;
  13.         double cup = 5;
  14.         double tShirt = 10.00;
  15.  
  16.         int counter = 0;
  17.  
  18.         while (counter < dwarfNum){
  19.             present = scanner.nextLine();
  20.             switch (present){
  21.                 case "sand clock":
  22.                     santaBudget -= sandClock;
  23.                     break;
  24.                 case "magnet":
  25.                     santaBudget -= magnet;
  26.                     break;
  27.                 case "cup":
  28.                     santaBudget -= cup;
  29.                     break;
  30.                 case "t-shirt":
  31.                     santaBudget -= tShirt;
  32.                     break;
  33.             }
  34.             counter ++;
  35.         }
  36.             if (santaBudget >= 0){
  37.                 System.out.printf("Santa Claus has %.2f more leva left!", santaBudget);
  38.             } else {
  39.                 System.out.printf("Santa Claus will need %.2f more leva.", Math.abs(santaBudget));
  40.             }
  41.     }
  42. }
Add Comment
Please, Sign In to add comment