Advertisement
galinyotsev123

ProgBasics07Nested-Loops-MoreExercisesY04HappyCatParking

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