Advertisement
desislava_topuzakova

09. Padawan Equipment

Jan 15th, 2021
1,188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.22 KB | None | 0 0
  1. package BasicSyntax;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PadawanEquipment_09 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         //Equipment: lightsabers, belts and robes
  9.         double money = Double.parseDouble(scanner.nextLine());
  10.         int students = Integer.parseInt(scanner.nextLine());
  11.         double priceLightsabers = Double.parseDouble(scanner.nextLine());
  12.         double priceRobes = Double.parseDouble(scanner.nextLine());
  13.         double priceBelts = Double.parseDouble(scanner.nextLine());
  14.  
  15.         //sabresPrice*(studentsCount + 10%) + robesPrice * (studentsCount) + beltsPrice*(studentsCount-freeBelts)
  16.         double totalPriceSabers = priceLightsabers * Math.ceil(students * 1.1);
  17.         double totalPriceRobes = students * priceRobes;
  18.         double totalPriceBelts = (students - students / 6) * priceBelts;
  19.  
  20.         double totalPrice = totalPriceBelts + totalPriceRobes + totalPriceSabers;
  21.         if(totalPrice <= money) {
  22.             System.out.printf("The money is enough - it would cost %.2flv.", totalPrice);
  23.         } else {
  24.             System.out.printf("Ivan Cho will need %.2flv more.",  totalPrice - money);
  25.         }
  26.  
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement