Advertisement
Deiancom

HappyCatParking

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