SvetlanPetrova

PadawanEquipment SoftUni

May 30th, 2021 (edited)
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class PadawanEquipment {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double budget = Double.parseDouble(scanner.nextLine());
  8.         int studentsCount = Integer.parseInt(scanner.nextLine());
  9.         double priceLight = Double.parseDouble(scanner.nextLine());
  10.         double priceRobe = Double.parseDouble(scanner.nextLine());
  11.         double priceBelt = Double.parseDouble(scanner.nextLine());
  12.  
  13.         double sumLight = Math.ceil(studentsCount + 0.10 * studentsCount) * priceLight;;
  14.         double sumRobes = studentsCount * priceRobe;
  15.         double sumBelts = (studentsCount - studentsCount / 6) * priceBelt;
  16.  
  17.         double totalSum = sumLight + sumRobes + sumBelts; //крайната сума за плащане
  18.  
  19.         if(totalSum <= budget) {
  20.             System.out.printf("The money is enough - it would cost %.2flv.", totalSum);
  21.         } else {
  22.             double needMoney = totalSum - budget;
  23.             System.out.printf("George Lucas will need %.2flv more.", needMoney);
  24.         }
  25.  
  26.     }
  27. }
  28.  
Add Comment
Please, Sign In to add comment