Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package OLD_MID_EXAMs_18_12_18;
- import java.util.Scanner;
- public class _01_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 ornamentSet = 2;
- int treeSkirt = 5;
- int treeGarlands = 3;
- int treeLights = 15;
- int costs = 0;
- int spirit = 0;
- for (int i = 1; i <= days; i++) {
- if (i % 11 == 0){
- quantity += 2;
- }
- if (i % 10 == 0){
- spirit -= 20;
- costs += (treeSkirt + treeGarlands + treeLights);
- if (i == days){
- spirit -= 30;
- }
- }
- if (i % 5 == 0){
- costs += (treeLights * quantity);
- spirit += 17;
- if (i % 3 == 0){ //допускам, че и 10-я ден влиза в това условие, но не съм сигурна
- spirit += 30;
- }
- }
- if (i % 3 == 0){
- costs += ((treeSkirt + treeGarlands) * quantity);
- spirit += 13;
- }
- if (i % 2 == 0){
- costs += (ornamentSet * quantity);
- spirit += 5;
- }
- }
- System.out.println("Total cost: " + costs);
- System.out.println("Total spirit: " + spirit);
- }
- }
- ................................
- package OLD_MID_EXAMs_18_12_18;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- import java.util.stream.Collectors;
- public class _02_SantasList {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- List<String> kids = Arrays.stream(scanner.nextLine()
- .split("&"))
- .collect(Collectors.toList());
- String input = "";
- while (!"Finished!".equals(input = scanner.nextLine())) {
- String[] lineArr = input.split("\\s+");
- String command = lineArr[0].trim(); //за всеки случай, да не остане спейс,защото няма да мачне
- switch (command) {
- case "Bad":
- if (!kids.contains(lineArr[1])) {
- kids.add(0, lineArr[1]);
- }
- break;
- case "Good":
- kids.remove(lineArr[1]);
- break;
- case "Rename":
- if (kids.contains(lineArr[1])) {
- kids.set(kids.indexOf(lineArr[1]), lineArr[2]);
- }
- break;
- case "Rearrange":
- if (kids.contains(lineArr[1])) {
- kids.remove(lineArr[1]);
- kids.add(lineArr[1]);
- }
- break;
- }
- }
- System.out.println(kids.toString().replaceAll("[\\[\\]]", ""));
- }
- }
- ................................................
- package OLD_MID_EXAMs_18_12_18;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.Scanner;
- import java.util.stream.Collectors;
- public class _03_PresentDelivery {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- List<Integer> numbers = Arrays.stream(scanner.nextLine()
- .split("@"))
- .map(Integer::parseInt)
- .collect(Collectors.toList());
- String input = "";
- int currentIndex = 0;
- while (!"Merry Xmas!".equals(input = scanner.nextLine())) {
- String[] command = input.split("\\s+");
- int steps = Integer.parseInt(command[1].trim());
- //bounding the currentIndex (position):
- if (currentIndex + steps >= numbers.size()) {
- currentIndex = (currentIndex + steps) % numbers.size();
- } else {
- currentIndex += steps;
- }
- if (numbers.get(currentIndex) == 0) {
- System.out.printf("House %d will have a Merry Christmas.%n", currentIndex);
- } else {
- numbers.set(currentIndex, numbers.get(currentIndex)-2);
- }
- }
- //print that in any case:
- System.out.printf("Santa's last position was %d.%n", currentIndex);
- //to find now many houses've been successfully delivered:
- int countHouse = 0;
- for (Integer number : numbers) {
- if (number == 0){
- countHouse++;
- }
- }
- if (countHouse == numbers.size()) {
- System.out.println("Mission was successful.");
- } else {
- System.out.printf("Santa has failed %d houses.%n",
- numbers.size() - countHouse);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement