Advertisement
Spocoman

Happy Cat Parking

Sep 7th, 2024 (edited)
966
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  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 total = 0;
  9.  
  10.         for (int day = 1; day <= days; day++) {
  11.             double sum = 0;
  12.  
  13.             for (int hour = 1; hour <= hours; hour++) {
  14.                 if (day % 2 == 0 && hour % 2 == 1) {
  15.                     sum += 2.50;
  16.                 } else if (day % 2 == 1 && hour % 2 == 0) {
  17.                     sum += 1.25;
  18.                 } else {
  19.                     sum++;
  20.                 }
  21.             }
  22.             System.out.printf("Day: %d - %.2f leva\n", day, sum);
  23.             total += sum;
  24.         }
  25.  
  26.         System.out.printf("Total: %.2f leva\n", total);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement