SHARE
TWEET

Padawan Equipment

elvirynwa Mar 21st, 2019 79 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 lightsabresPrice = Double.parseDouble(scanner.nextLine());
  10.         double robesPrice = Double.parseDouble(scanner.nextLine());
  11.         double beltsPrice = Double.parseDouble(scanner.nextLine());
  12.  
  13.         double totalPrice = 0;
  14.  
  15.  
  16.         double sabresMore = Math.ceil(studentsCount * 1.10);
  17.  
  18.         double totalSabresPrice = lightsabresPrice *  sabresMore;
  19.         double totalRobesPrice = robesPrice * studentsCount;
  20.         double freeBelts = studentsCount - (studentsCount / 6);
  21.         double totalBeltsPrice = beltsPrice * freeBelts;
  22.  
  23.         totalPrice = totalSabresPrice + totalRobesPrice + totalBeltsPrice;
  24.  
  25.         double diffPrice = budget - totalPrice;
  26.  
  27.         if (totalPrice <= budget) {
  28.             System.out.printf("The money is enough - it would cost %.2flv.", totalPrice);
  29.         }else {
  30.             System.out.printf("Ivan Cho will need %.2flv more.",Math.abs(diffPrice));
  31.         }
  32.     }
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top