Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- final static double LABOR_PRICE_PER_HOUR = 18.00;
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- System.out.println("Wprowadź liczbe pokojów: ");
- int rooms = input.nextInt();
- System.out.println("Podaj cenę farby");
- double paintPrice = input.nextDouble();
- System.out.println("Podaj powierzchnię do pomalowania");
- double surface = 0;
- for (int i = 0; i < rooms; i++)
- {
- System.out.println("Powierzchnia pokoju " + (i + 1));
- surface += input.nextDouble();
- }
- System.out.printf("Potrzebne litry: %.2fl\n", getPaintRequired(surface));
- System.out.printf("Potrzebne godziny pracy: %.2fh\n", getLaborHoursRequired(surface));
- System.out.printf("Koszt farby %.2fzł\n", getPaintCost(paintPrice, surface));
- System.out.printf("Koszt robocizny: %.2fzł\n", getLaborCost(surface));
- System.out.printf("Lączny koszt malowania: %.2fzł\n", getTotalCost(surface, paintPrice));
- }
- public static double getPaintRequired(double surface)
- {
- return surface / 10 * 1.5;
- }
- public static double getLaborHoursRequired(double surface)
- {
- return surface / 10 * 8;
- }
- public static double getPaintCost(double paintPrice, double surface)
- {
- return paintPrice * getPaintRequired(surface);
- }
- public static double getLaborCost(double surface)
- {
- return LABOR_PRICE_PER_HOUR * getLaborHoursRequired(surface);
- }
- public static double getTotalCost(double surface, double paintPrice)
- {
- return getLaborCost(surface) + getPaintCost(paintPrice, surface);
- }
- }
Advertisement