Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class IntroPagawanEquipment {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double money = Double.parseDouble(scanner.nextLine());
  8.  
  9. int countStudents = Integer.parseInt(scanner.nextLine());
  10.  
  11. double lightSabresPrice = Double.parseDouble(scanner.nextLine());
  12. double robesPrice = Double.parseDouble(scanner.nextLine());
  13. double beltsPrice = Double.parseDouble(scanner.nextLine());
  14.  
  15. double allRopes = robesPrice * countStudents;
  16. double allBelts =0;
  17.  
  18. double allLightSabre = lightSabresPrice * (countStudents + Math.ceil(countStudents * 0.1));
  19.  
  20.  
  21. if (countStudents >=6){
  22. allBelts = beltsPrice * ((countStudents - countStudents/6d));
  23. }else {
  24. allBelts = beltsPrice * countStudents;
  25. }
  26.  
  27. double price = allLightSabre + allRopes + allBelts;
  28.  
  29. if (money >= price){
  30. System.out.printf("The money is enough - it would cost %.2flv.",price);
  31. }else {
  32. System.out.printf("Ivan Cho will need %.2flv more.", Math.abs(price - money));
  33. }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement