grach

Vet Parking - Exam 2-3 May 2019

Apr 23rd, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.90 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class VetParking {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         int days = Integer.parseInt(scan.nextLine());
  8.         int hours = Integer.parseInt(scan.nextLine());
  9.  
  10.         double ticket = 0;
  11.         double sumDay = 0;
  12. double sumTicket = 0 ;
  13.  
  14.         for (int i = 0; i < days; i++) {
  15.  
  16.             for (int j = 0; j < hours; j++) {
  17.  
  18.                 if ((j % 2 != 0) && (i % 2 == 0)) {
  19.                     ticket = 1.25;
  20.                 } else if ((j % 2 == 0) && (i % 2 != 0)) {
  21.                     ticket = 2.50;
  22.                 } else {
  23.                     ticket = 1;
  24.                 }
  25.                 sumDay += ticket;
  26.  
  27.             }
  28.            // sumTicket = ticket;
  29.             System.out.println("SumDay " + sumDay);
  30.         }
  31.  
  32.         System.out.println("SumTotal " + sumDay);
  33.  
  34.     }
  35. }
Add Comment
Please, Sign In to add comment