Advertisement
veronikaaa86

01. Agency Profit

Apr 22nd, 2023
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.93 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P01AgencyProfit {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String name = scanner.nextLine();
  10.         int adultTicketCount = Integer.parseInt(scanner.nextLine());
  11.         int kidsTicketCount = Integer.parseInt(scanner.nextLine());
  12.         double priceAdult = Double.parseDouble(scanner.nextLine());
  13.         double priceService = Double.parseDouble(scanner.nextLine());
  14.  
  15.         double priceKids = priceAdult * 0.30;
  16.         double adultWithService = priceAdult + priceService;
  17.         double kidsWithService = priceKids + priceService;
  18.         double totalTicketsPrice = (adultTicketCount * adultWithService) + (kidsTicketCount * kidsWithService);
  19.  
  20.         double result = totalTicketsPrice * 0.20;
  21.  
  22.         System.out.printf("The profit of your agency from %s tickets is %.2f lv.", name, result);
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement