Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class IntroPagawanEquipment {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double money = Double.parseDouble(scanner.nextLine());
- int countStudents = Integer.parseInt(scanner.nextLine());
- double lightSabresPrice = Double.parseDouble(scanner.nextLine());
- double robesPrice = Double.parseDouble(scanner.nextLine());
- double beltsPrice = Double.parseDouble(scanner.nextLine());
- double allRopes = robesPrice * countStudents;
- double allBelts =0;
- double allLightSabre = lightSabresPrice * (countStudents + Math.ceil(countStudents * 0.1));
- if (countStudents >=6){
- allBelts = beltsPrice * ((countStudents - countStudents/6d));
- }else {
- allBelts = beltsPrice * countStudents;
- }
- double price = allLightSabre + allRopes + allBelts;
- if (money >= price){
- System.out.printf("The money is enough - it would cost %.2flv.",price);
- }else {
- System.out.printf("Ivan Cho will need %.2flv more.", Math.abs(price - money));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement