Advertisement
Guest User

Untitled

a guest
Mar 6th, 2017
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ex02ChangeTiles {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double savings = Double.parseDouble(scanner.nextLine());
  8.         double floorWidth = Double.parseDouble(scanner.nextLine());
  9.         double floorLength = Double.parseDouble(scanner.nextLine());
  10.         double tileTriangleSide = Double.parseDouble(scanner.nextLine());
  11.         double tileTriangleHeight = Double.parseDouble(scanner.nextLine());
  12.         double pricePerTile = Double.parseDouble(scanner.nextLine());
  13.         double workerWage = Double.parseDouble(scanner.nextLine());
  14.  
  15.         double floorArea = floorWidth * floorLength;
  16.         double tileArea = tileTriangleHeight * tileTriangleSide / 2;
  17.  
  18.         int tilesNeeded = (int) Math.ceil(floorArea / tileArea) + 5;
  19.  
  20.         double totalCost = pricePerTile * tilesNeeded + workerWage;
  21.  
  22.         if (savings < totalCost) {
  23.             System.out.printf("You'll need %.2f lv more.%n", totalCost - savings);
  24.         } else {
  25.             System.out.printf("%.2f lv left.%n", savings - totalCost);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement