myrdok123

05. Supplies for School

Apr 23rd, 2023
909
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.54 KB | None | 0 0
  1. package L01_FirstStepsInCoding_EXC;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05_SuppliesForSchool {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.  
  11.         //1. Прочитаме входните данни
  12.         //2. Пресметнем цената за химикали, маркери и почистващ препарат
  13.         //3. Пресметнем отстъпка -> пресмятаме общата сума -> пресмятаме отстъпката на база процента, който сме прочели
  14.         //4. Пресметнем общата сума
  15.         //5. Принтираме
  16.  
  17.         int countPenPackages = Integer.parseInt(scanner.nextLine());
  18.         int countHighlightersPackages = Integer.parseInt(scanner.nextLine());
  19.         int cleaningAgentLitres = Integer.parseInt(scanner.nextLine());
  20.         int discount = Integer.parseInt(scanner.nextLine());
  21.  
  22.         //•   Пакет химикали - 5.80 лв.
  23.         //•   Пакет маркери - 7.20 лв.
  24.         //•   Препарат - 1.20 лв (за литър)
  25.  
  26.         double penPrice = countPenPackages * 5.80;
  27.         double highlightersPrice = countHighlightersPackages * 7.20;
  28.         double cleaningAgentPrice = cleaningAgentLitres * 1.20;
  29.  
  30.         double sumWithoutDiscount = penPrice + highlightersPrice + cleaningAgentPrice;
  31.  
  32.         double finalSum = sumWithoutDiscount - (sumWithoutDiscount * (discount / 100.0));
  33.  
  34.         System.out.println(finalSum);
  35.  
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment