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