Advertisement
Lyuben_Andreev

Untitled

May 31st, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.55 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.         int quantity = Integer.parseInt(scanner.nextLine());
  10.         int days = Integer.parseInt(scanner.nextLine());
  11.         int ornamentSet = 2;
  12.         int threeSkirt = 5;
  13.         int threeGarlands = 3;
  14.         int threeLights = 15;
  15.         int spirit = 0;
  16.  
  17.  
  18.         for (int i = quantity; i <= days; i++) {
  19.             if (i % 2 == 0 ){
  20.                  quantity = quantity + ornamentSet;
  21.                  spirit = spirit + 5;
  22.  
  23.             }
  24.             if (i % 3 == 0){
  25.                 quantity = quantity + threeSkirt + threeGarlands;
  26.                 spirit = spirit + 13;
  27.             }if (i % 5 == 0){
  28.                 quantity = quantity + threeLights;
  29.                 spirit = spirit + 17;
  30.                 if (quantity == days){
  31.                     quantity = quantity + threeSkirt + threeGarlands;
  32.                     spirit = spirit + 30;
  33.                 }
  34.             }if (i % 10 == 0) {
  35.                 spirit = spirit - 20;
  36.                 quantity = quantity + ornamentSet + threeSkirt + threeGarlands + threeLights;
  37.             }
  38.                 if(days == 10){
  39.                     spirit = spirit - 30;
  40.  
  41.  
  42.  
  43.             }if (days % 11 == 0){
  44.                 quantity = quantity + 2;
  45.             }
  46.  
  47.         }
  48.  
  49.         System.out.println(String.format("Total cost: %d", quantity));
  50.         System.out.println(String.format("Total spirit: %d", spirit));
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement