Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class P17_Dwarf {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double dwarfNum = Integer.parseInt(scanner.nextLine());
- double santaBudget = Integer.parseInt(scanner.nextLine());
- String present = "";
- double sandClock = 2.20;
- double magnet = 1.50;
- double cup = 5;
- double tShirt = 10.00;
- int counter = 0;
- while (counter < dwarfNum){
- present = scanner.nextLine();
- switch (present){
- case "sand clock":
- santaBudget -= sandClock;
- break;
- case "magnet":
- santaBudget -= magnet;
- break;
- case "cup":
- santaBudget -= cup;
- break;
- case "t-shirt":
- santaBudget -= tShirt;
- break;
- }
- counter ++;
- }
- if (santaBudget >= 0){
- System.out.printf("Santa Claus has %.2f more leva left!", santaBudget);
- } else {
- System.out.printf("Santa Claus will need %.2f more leva.", Math.abs(santaBudget));
- }
- }
- }
Add Comment
Please, Sign In to add comment