Advertisement
Qnko941

Untitled

Jan 19th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Fundamentals9 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double availableMoney = Double.parseDouble(scanner.nextLine());
  8. int studentCount = Integer.parseInt(scanner.nextLine());
  9. double saberPrice = Double.parseDouble(scanner.nextLine());
  10. double robePrice = Double.parseDouble(scanner.nextLine());
  11. double beltPrice = Double.parseDouble(scanner.nextLine());
  12. double freebelts = 0.00;
  13.  
  14. for (int i = 1; i <= studentCount; i++) {
  15. if (i % 6 == 0) {
  16. freebelts += beltPrice;
  17. }
  18. }
  19. double moneyNeeded = (saberPrice * Math.ceil(studentCount * 1.10)) + (robePrice * studentCount) + (studentCount * beltPrice) - freebelts;
  20.  
  21. if (availableMoney <= moneyNeeded) {
  22. System.out.printf("Ivan Cho will need %.2flv more.", moneyNeeded - availableMoney);
  23. } else {
  24. System.out.printf("The money is enough - it would cost %.2flv.", moneyNeeded);
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement