Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ExamPreparation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //цена на ракети = бр. ракети * ед.цена за ракета
- //цена за маратонки = бр. маратонки * ед. цена за маратонки ( 1/6 от ед.цена за ракета)
- //цена за екипировка = 20% от (цена за ракети + цена за маратонки)
- //разходи = ракети + маратонки + екипировка
- //Джокович = 1/8 от разходи (floor)
- //спонсори = 7/8 от разходите (ceil)
- double pricePerRacket = Double.parseDouble(scanner.nextLine());
- int countRackets = Integer.parseInt(scanner.nextLine());
- int countTrainers = Integer.parseInt(scanner.nextLine());
- double priceRackets = countRackets * pricePerRacket;
- double priceTrainers = countTrainers * (pricePerRacket / 6);
- double priceEquipment = 0.2 * (priceRackets + priceTrainers);
- double expenses = priceRackets + priceTrainers + priceEquipment;
- double paidByDjokovic = expenses / 8;
- double paidBySponsors = 7 * expenses / 8;
- System.out.printf("Price to be paid by Djokovic %.0f%n", Math.floor(paidByDjokovic));
- System.out.printf("Price to be paid by sponsors %.0f", Math.ceil(paidBySponsors));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment