Advertisement
Osiris1002

Vet Parking

Dec 17th, 2022
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.20 KB | None | 0 0
  1. package IZPIT;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Vet_Parking {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         int days = Integer.parseInt(scan.nextLine());
  10.         int hours = Integer.parseInt(scan.nextLine());
  11.         double totalCharge = 0.0;
  12.         double hourCharge = 0.0;
  13.         double dayCharge = 0.0;
  14.         int hourCount = 0;
  15.  
  16.         for (int i = 1; i <= days ; i++) {
  17.  
  18.             for (int j = 1; j <= hours; j++) {
  19.                 hourCount++;
  20.  
  21.                 if (i % 2 == 0 && j % 2 != 0) {
  22.  
  23.                     hourCharge = 2.50;
  24.  
  25.                 } else if (i % 2 != 0 && j % 2 == 0) {
  26.  
  27.                     hourCharge = 1.25;
  28.  
  29.                 } else {
  30.  
  31.                     hourCharge = 1;
  32.  
  33.                 }
  34.  
  35.                 totalCharge += hourCharge;
  36.                 dayCharge += hourCharge;
  37.                 if(hourCount == hours){
  38.                     System.out.printf("Day: %d - %.2f leva%n" , i , dayCharge );
  39.                     hourCount = 0;
  40.                     dayCharge = 0;
  41.                 }
  42.             }
  43.         }
  44.             System.out.printf("Total: %.2f leva" , totalCharge);
  45.  
  46.     }
  47. }
  48.  
  49.  
Tags: Vet Parking
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement