Didart

Padawan Equipment

Sep 20th, 2021
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. package src;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PadawanEquipment {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double money = Double.parseDouble(scanner.nextLine());
  10.         int studentsCount = Integer.parseInt(scanner.nextLine());
  11.         double lightSabersPrice = Double.parseDouble(scanner.nextLine());
  12.         double robesPrice = Double.parseDouble(scanner.nextLine());
  13.         double beltsPrice = Double.parseDouble(scanner.nextLine());
  14.  
  15.         double sumLightSabers = lightSabersPrice * Math.ceil(studentsCount + 0.10 * studentsCount);   //studentsCount * 1.1;
  16.         double sumRobes = studentsCount * robesPrice;
  17.         double sumBelts = (studentsCount - studentsCount / 6) * beltsPrice;
  18.  
  19.         double totalSum = sumLightSabers + sumRobes + sumBelts;
  20.  
  21.         if (totalSum <= money) {
  22.             System.out.printf("The money is enough - it would cost %.2flv.",
  23.                     totalSum);
  24.         } else {
  25.             double needMoney = totalSum - money;
  26.             System.out.printf("George Lucas will need %.2flv more.", needMoney);
  27.         }
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment