Advertisement
desislava_topuzakova

09.PadawanEquipment

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