Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ProgrammingBasics.NestedLoops;
- import java.util.Scanner;
- public class HappyCatParking11 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int dayNumber = Integer.parseInt(scanner.nextLine());
- int hours = Integer.parseInt(scanner.nextLine());
- double sumForAllDays = 0;
- for (int i = 1; i <= dayNumber; i++) {
- double sum = 0;
- for (int j = 1; j <= hours; j++) {
- if (i % 2 == 0 && j % 2 != 0) {
- sum += 2.50;
- sumForAllDays += 2.50;
- } else if (i % 2 != 0 && j % 2 == 0) {
- sum += 1.25;
- sumForAllDays += 1.25;
- } else {
- sum += 1;
- sumForAllDays += 1;
- }
- }
- System.out.printf("Day: %d - %.2f leva%n", i, sum);
- }
- System.out.printf("Total: %.2f leva", sumForAllDays);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement