Advertisement
myrdok123

P06VetParking

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