Advertisement
Spocoman

11. HappyCat Parking

Aug 30th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class HappyCatParking {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int days = Integer.parseInt(scanner.nextLine()),
  7.                 hours = Integer.parseInt(scanner.nextLine());
  8.         double totalPrice = 0;
  9.  
  10.         for (int i = 1; i <= days; i++) {
  11.             double dayPrice = 0;
  12.             for (int j = 1; j <= hours; j++) {
  13.  
  14.                 if (i % 2 == 0 && j % 2 == 1) {
  15.                     dayPrice += 2.50;
  16.                 } else if (i % 2 == 1 && j % 2 == 0) {
  17.                     dayPrice += 1.25;
  18.                 } else {
  19.                     dayPrice++;
  20.                 }
  21.             }
  22.             totalPrice += dayPrice;
  23.             System.out.printf("Day: %d - %.2f leva\n", i, dayPrice);
  24.         }
  25.         System.out.printf("Total: %.2f leva\n", totalPrice);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement