Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fundamentalsExam;
- import java.util.Scanner;
- public class christmasSpirit {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int quantity = Integer.parseInt(scanner.nextLine());
- int days = Integer.parseInt(scanner.nextLine());
- int period = 1;
- int christmasSpirit = 0;
- int cost = 0;
- int ornamentPrice = 2;
- int treeSkirt = 5;
- int gerland = 3;
- int lights = 15;
- while(days > 0){
- if(period % 11 ==0){
- quantity += 2;
- }
- if(period % 2 == 0){
- cost += ornamentPrice * quantity;
- christmasSpirit += 5;
- }
- if(period % 3 == 0){
- cost += treeSkirt * quantity;
- cost += gerland * quantity;
- christmasSpirit += 13;
- }
- if(period % 5 == 0){
- cost += lights * quantity;
- christmasSpirit += 17;
- }
- if(period % 5 == 0 && period % 3 == 0){
- christmasSpirit += 30;
- }
- if(period % 10 == 0){
- christmasSpirit -= 20;
- cost += lights + gerland + treeSkirt;
- }
- if(period % 10 == 0 && days == 1){
- christmasSpirit -= 30;
- }
- period++;
- days--;
- }
- System.out.println("Total cost: " + cost);
- System.out.println("Total spirit: " + christmasSpirit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement