Advertisement
UKTC162

main

Jun 17th, 2020
1,239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1.  
  2. public class Main {
  3.  
  4.     public static void main(String[] args) {
  5.  
  6.         Ticket[] tickets = {new Ticket("Mozart", 250.00), new Ticket("Mozart", 250.00), new DiscountTicket("Mozart", 250.00, "John Smith"), new GroupTicket("Mozart", 250.00, 20)};
  7.  
  8.         getInfo(tickets);
  9.  
  10.     }
  11.  
  12.     public static void getInfo(Ticket[] tickets) {
  13.         int people = 0;
  14.         double sum = 0;
  15.  
  16.         for(int i=0;i<tickets.length;i++) {
  17.             people = people + tickets[i].getPeople();
  18.             sum += tickets[i].getPrice();
  19.         }
  20.  
  21.         System.out.println("Number of people from these tickets: "+people);
  22.         System.out.println("The total sum of these tickets: "+sum);
  23.     }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement