Advertisement
veronikaaa86

06. Vet Parking

Oct 22nd, 2022
983
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P06VetParking {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int countDays = Integer.parseInt(scanner.nextLine());
  10.         int countHours = Integer.parseInt(scanner.nextLine());
  11.        
  12.         double totalSum = 0;
  13.         for (int day = 1; day <= countDays; day++) {
  14.             double price = 0;
  15.             double currentDaySum = 0;
  16.             for (int hour = 1; hour <= countHours; hour++) {
  17.                 if (day % 2 == 0 && hour % 2 != 0) {
  18.                     price = 2.5;
  19.                 } else if (day % 2 != 0 && hour % 2 == 0) {
  20.                     price = 1.25;
  21.                 } else {
  22.                     price = 1;
  23.                 }
  24.                 currentDaySum = currentDaySum + price;
  25.             }
  26.             totalSum = totalSum + currentDaySum;
  27.             System.out.printf("Day: %d - %.2f leva%n", day, currentDaySum);
  28.         }
  29.  
  30.         System.out.printf("Total: %.2f leva%n", totalSum);
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement