Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class PadawanEquipment {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double budget = Double.parseDouble(scanner.nextLine());
- int studentsCount = Integer.parseInt(scanner.nextLine());
- double lightsabresPrice = Double.parseDouble(scanner.nextLine());
- double robesPrice = Double.parseDouble(scanner.nextLine());
- double beltsPrice = Double.parseDouble(scanner.nextLine());
- double totalPrice = 0;
- double sabresMore = Math.ceil(studentsCount * 1.10);
- double totalSabresPrice = lightsabresPrice * sabresMore;
- double totalRobesPrice = robesPrice * studentsCount;
- double freeBelts = studentsCount - (studentsCount / 6);
- double totalBeltsPrice = beltsPrice * freeBelts;
- totalPrice = totalSabresPrice + totalRobesPrice + totalBeltsPrice;
- double diffPrice = budget - totalPrice;
- if (totalPrice <= budget) {
- System.out.printf("The money is enough - it would cost %.2flv.", totalPrice);
- }else {
- System.out.printf("Ivan Cho will need %.2flv more.",Math.abs(diffPrice));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement