Advertisement
Guest User

christmasSpirit

a guest
Dec 8th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.59 KB | None | 0 0
  1. package fundamentalsExam;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class christmasSpirit {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         int quantity = Integer.parseInt(scanner.nextLine());
  9.         int days = Integer.parseInt(scanner.nextLine());
  10.         int period = 1;
  11.  
  12.         int christmasSpirit = 0;
  13.         int cost = 0;
  14.  
  15.         int ornamentPrice = 2;
  16.         int treeSkirt = 5;
  17.         int gerland = 3;
  18.         int lights = 15;
  19.  
  20.         while(days > 0){
  21.  
  22.             if(period % 11 ==0){
  23.                 quantity += 2;
  24.             }
  25.  
  26.             if(period % 2 == 0){
  27.                 cost += ornamentPrice * quantity;
  28.                 christmasSpirit += 5;
  29.             }
  30.  
  31.             if(period % 3 == 0){
  32.                 cost += treeSkirt * quantity;
  33.                 cost += gerland * quantity;
  34.                 christmasSpirit += 13;
  35.             }
  36.  
  37.             if(period % 5 == 0){
  38.                 cost += lights * quantity;
  39.                 christmasSpirit += 17;
  40.             }
  41.  
  42.             if(period % 5 == 0 && period % 3 == 0){
  43.                 christmasSpirit += 30;
  44.             }
  45.  
  46.             if(period % 10 == 0){
  47.                 christmasSpirit -= 20;
  48.                 cost += lights + gerland + treeSkirt;
  49.             }
  50.  
  51.             if(period % 10 == 0 && days == 1){
  52.                 christmasSpirit -= 30;
  53.             }
  54.  
  55.  
  56.             period++;
  57.             days--;
  58.         }
  59.  
  60.         System.out.println("Total cost: " + cost);
  61.         System.out.println("Total spirit: " + christmasSpirit);
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement