Advertisement
meteor4o

09. Padawan Equipment

May 20th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Main {
  4. public static void main(String[] args) {
  5. Scanner sc = new Scanner(System.in);
  6.  
  7. double money = Double.parseDouble(sc.nextLine());
  8. int students = Integer.parseInt(sc.nextLine());
  9. double saberPrice = Double.parseDouble(sc.nextLine());
  10. double robePrice = Double.parseDouble(sc.nextLine());
  11. double beltPrice = Double.parseDouble(sc.nextLine());
  12. double totalPrice = 0.0;
  13.  
  14. int freeBelts = students / 6;
  15.  
  16. totalPrice = (Math.ceil(students * 1.1) * saberPrice) + students * robePrice + (students - freeBelts) * beltPrice;
  17.  
  18.  
  19.  
  20.  
  21. if(money >= totalPrice) {
  22. System.out.printf("The money is enough - it would cost %.2flv.", totalPrice);
  23. } else {
  24. System.out.printf("Ivan Cho will need %.2flv more.", totalPrice - money);
  25. }
  26.  
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement