grodek118

Paint Job Estimator v2

May 24th, 2023
809
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     final static double LABOR_PRICE_PER_HOUR = 18.00;
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner input = new Scanner(System.in);
  10.  
  11.         System.out.println("Wprowadź liczbe pokojów: ");
  12.         int rooms = input.nextInt();
  13.         System.out.println("Podaj cenę farby");
  14.         double paintPrice = input.nextDouble();
  15.         System.out.println("Podaj powierzchnię do pomalowania");
  16.         double surface = 0;
  17.  
  18.         for (int i = 0; i < rooms; i++)
  19.         {
  20.             System.out.println("Powierzchnia pokoju " + (i + 1));
  21.             surface += input.nextDouble();
  22.         }
  23.  
  24.         System.out.printf("Potrzebne litry: %.2fl\n", getPaintRequired(surface));
  25.         System.out.printf("Potrzebne godziny pracy: %.2fh\n", getLaborHoursRequired(surface));
  26.         System.out.printf("Koszt farby %.2fzł\n", getPaintCost(paintPrice, surface));
  27.         System.out.printf("Koszt robocizny: %.2fzł\n", getLaborCost(surface));
  28.         System.out.printf("Lączny koszt malowania: %.2fzł\n", getTotalCost(surface, paintPrice));
  29.     }
  30.  
  31.     public static double getPaintRequired(double surface)
  32.     {
  33.         return surface / 10 * 1.5;
  34.     }
  35.  
  36.     public static double getLaborHoursRequired(double surface)
  37.     {
  38.         return surface / 10 * 8;
  39.     }
  40.  
  41.     public static double getPaintCost(double paintPrice, double surface)
  42.     {
  43.         return paintPrice * getPaintRequired(surface);
  44.     }
  45.  
  46.     public static double getLaborCost(double surface)
  47.     {
  48.         return LABOR_PRICE_PER_HOUR * getLaborHoursRequired(surface);
  49.     }
  50.  
  51.     public static double getTotalCost(double surface, double paintPrice)
  52.     {
  53.         return getLaborCost(surface) + getPaintCost(paintPrice, surface);
  54.     }
  55. }
  56.  
Advertisement
Comments
Add Comment
Please, Sign In to add comment