Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.nio.charset.IllegalCharsetNameException;
- import java.util.Scanner;
- public class TennisEquipment_0101 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //read:
- // price for one racket
- double racketPrice = Double.parseDouble(scanner.nextLine());
- // number of tennis rackets to buy
- int numberRackets = Integer.parseInt(scanner.nextLine());
- // number of sport shoes to buy
- int numberShoes = Integer.parseInt(scanner.nextLine());
- // pair of shoes = 1/6 of racket price
- double shoesPrice = racketPrice / 6;
- // other equipment needed = 20% of sum rackets+shoes
- double sumMoney = (racketPrice * numberRackets) + (shoesPrice * numberShoes);
- sumMoney = sumMoney + (sumMoney * 0.2);
- // Print:
- //price ti be paid bu Djokovic = sumMoney * 1/8
- double sumDjokovic = Math.floor(sumMoney / 8);
- System.out.printf("Price to be paid by Djokovic %.0f%n", sumDjokovic);
- //price to pay the sponsor = rest
- double sumSponsor = Math.ceil(sumMoney * 7 / 8);
- System.out.printf("Price to be paid by sponsors %.0f", sumSponsor);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement