Advertisement
IvaAnd

TennisEquipmentMarch2019

Mar 28th, 2020
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. import java.nio.charset.IllegalCharsetNameException;
  2. import java.util.Scanner;
  3.  
  4. public class TennisEquipment_0101 {
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. //read:
  9. // price for one racket
  10. double racketPrice = Double.parseDouble(scanner.nextLine());
  11. // number of tennis rackets to buy
  12. int numberRackets = Integer.parseInt(scanner.nextLine());
  13. // number of sport shoes to buy
  14. int numberShoes = Integer.parseInt(scanner.nextLine());
  15.  
  16. // pair of shoes = 1/6 of racket price
  17. double shoesPrice = racketPrice / 6;
  18.  
  19. // other equipment needed = 20% of sum rackets+shoes
  20. double sumMoney = (racketPrice * numberRackets) + (shoesPrice * numberShoes);
  21. sumMoney = sumMoney + (sumMoney * 0.2);
  22.  
  23. // Print:
  24. //price ti be paid bu Djokovic = sumMoney * 1/8
  25. double sumDjokovic = Math.floor(sumMoney / 8);
  26. System.out.printf("Price to be paid by Djokovic %.0f%n", sumDjokovic);
  27.  
  28. //price to pay the sponsor = rest
  29. double sumSponsor = Math.ceil(sumMoney * 7 / 8);
  30. System.out.printf("Price to be paid by sponsors %.0f", sumSponsor);
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement