desislava_topuzakova

01. Tennis Equipment

Mar 20th, 2021
789
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class ExamPreparation {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         //цена на ракети = бр. ракети * ед.цена за ракета
  8.         //цена за маратонки = бр. маратонки * ед. цена за маратонки ( 1/6 от ед.цена за ракета)
  9.         //цена за екипировка = 20% от (цена за ракети + цена за маратонки)
  10.         //разходи = ракети + маратонки + екипировка
  11.         //Джокович = 1/8 от разходи (floor)
  12.         //спонсори = 7/8 от разходите (ceil)
  13.         double pricePerRacket = Double.parseDouble(scanner.nextLine());
  14.         int countRackets = Integer.parseInt(scanner.nextLine());
  15.         int countTrainers = Integer.parseInt(scanner.nextLine());
  16.  
  17.         double priceRackets = countRackets * pricePerRacket;
  18.         double priceTrainers = countTrainers * (pricePerRacket / 6);
  19.         double priceEquipment = 0.2 * (priceRackets + priceTrainers);
  20.  
  21.         double expenses = priceRackets + priceTrainers + priceEquipment;
  22.         double paidByDjokovic = expenses / 8;
  23.         double paidBySponsors = 7 * expenses / 8;
  24.  
  25.         System.out.printf("Price to be paid by Djokovic %.0f%n", Math.floor(paidByDjokovic));
  26.         System.out.printf("Price to be paid by sponsors %.0f", Math.ceil(paidBySponsors));
  27.  
  28.  
  29.  
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment