Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Fundamentals9 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double availableMoney = Double.parseDouble(scanner.nextLine());
- int studentCount = Integer.parseInt(scanner.nextLine());
- double saberPrice = Double.parseDouble(scanner.nextLine());
- double robePrice = Double.parseDouble(scanner.nextLine());
- double beltPrice = Double.parseDouble(scanner.nextLine());
- double freebelts = 0.00;
- for (int i = 1; i <= studentCount; i++) {
- if (i % 6 == 0) {
- freebelts += beltPrice;
- }
- }
- double moneyNeeded = (saberPrice * Math.ceil(studentCount * 1.10)) + (robePrice * studentCount) + (studentCount * beltPrice) - freebelts;
- if (availableMoney <= moneyNeeded) {
- System.out.printf("Ivan Cho will need %.2flv more.", moneyNeeded - availableMoney);
- } else {
- System.out.printf("The money is enough - it would cost %.2flv.", moneyNeeded);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement