Facebook
From Ivory Bushbaby, 2 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 70
  1. package com.company;
  2.  
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Main
  7. {
  8.     public static final Double SHOE_RATIO = 0.6;
  9.     public static final Double EQUIP_RATIO = 0.8;
  10.     public static final Double BALL_RATIO = 0.25;
  11.     public static final Double ACCESSORIES_RATIO = 0.2;
  12.  
  13.     public static final Double CHICKEN_PRICE = 10.35;
  14.     public static final Double FISH_PRICE = 12.40;
  15.     public static final Double VEGGIE_PRICE = 8.15;
  16.     public static final Double DELIVERY_PRICE = 2.50;
  17.  
  18.     public static void main(String[] args) {
  19.         Scanner scanner = new Scanner(System.in);
  20. //        int chicken = Integer.parseInt(scanner.nextLine());
  21. //        int fish = Integer.parseInt(scanner.nextLine());
  22. //        int veggie = Integer.parseInt(scanner.nextLine());
  23. //
  24. //        System.out.println( createMenu(chicken,fish,veggie));
  25.  
  26. //        int yearlyTax = Integer.parseInt(scanner.nextLine());
  27. //
  28. //        System.out.println(calculateGear(yearlyTax));
  29.  
  30.         int length = Integer.parseInt(scanner.nextLine());
  31.         int width = Integer.parseInt(scanner.nextLine());
  32.         int height = Integer.parseInt(scanner.nextLine());
  33.         double pct = Double.parseDouble(scanner.nextLine());
  34.  
  35.         System.out.println(calculateWater(length, width, height, pct));
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.     }
  43.  
  44.     private static Double calculateWater (int length, int width, int height, double pct){
  45.         double volumeAquarium = length * width * height;
  46.         double volumeLitres = volumeAquarium * 0.001;
  47.  
  48.         return volumeLitres - (volumeLitres * (pct / 100));
  49.     }
  50.  
  51.     private static Double calculateGear(int yearlyTax) {
  52.         double shoePrice = yearlyTax * SHOE_RATIO;
  53.         double equipPrice = shoePrice * EQUIP_RATIO;
  54.         double ballPrice = equipPrice * BALL_RATIO;
  55.         double accessoriesPrice = ballPrice * ACCESSORIES_RATIO;
  56.  
  57.         return shoePrice + equipPrice + ballPrice + accessoriesPrice + yearlyTax;
  58.     }
  59.  
  60.     private static Double createMenu(int chickenCount, int fishCount, int veggieCount){
  61.         double chickenCost = chickenCount * CHICKEN_PRICE;
  62.         double fishCost = fishCount * FISH_PRICE;
  63.         double veggieCost = veggieCount * VEGGIE_PRICE;
  64.  
  65.         double totalCost = chickenCost + fishCost + veggieCost;
  66.         double desert = totalCost * 0.2;
  67.         return totalCost + DELIVERY_PRICE + desert;
  68.     }
  69. }
  70.