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