Advertisement
desislava_topuzakova

01. Movie Profit

Oct 23rd, 2021
978
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.44 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MovieProfit_01 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         //1. сума от билетите за 1 ден = бр. билети * цена за 1 билет
  7.         //2. сума от билетите за всички дни = сума за билетите за 1 ден * бр. дни
  8.         //3. изчисляваме печалба за киното = процент * сума от билетите за всички дни
  9.         //4. крайна печалба = сума от билетите за всички дни - изчисляваме печалба за киното
  10.  
  11.         String movieName = scanner.nextLine();
  12.         int days = Integer.parseInt(scanner.nextLine()); //общ брой дни
  13.         int ticketsPerDay = Integer.parseInt(scanner.nextLine()); //билети за 1 ден
  14.         double pricePerTicket = Double.parseDouble(scanner.nextLine());
  15.         int percentForCinema = Integer.parseInt(scanner.nextLine());
  16.  
  17.         double sumPerDay = ticketsPerDay * pricePerTicket; //сума за ден
  18.         double totalSum = sumPerDay * days; //сума за всички дни
  19.         double profitCinema = totalSum * (percentForCinema / 100.0);
  20.         double profitStudio = totalSum - profitCinema;
  21.         System.out.printf("The profit from the movie %s is %.2f lv.", movieName, profitStudio);
  22.  
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement