Advertisement
r1s7o

Tile Change Exam 18 Dec 2016

Mar 6th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Tile_Change {
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         Scanner console = new Scanner(System.in);
  9.         double money = Double.parseDouble(console.nextLine());
  10.         double a = Double.parseDouble(console.nextLine());
  11.         double b = Double.parseDouble(console.nextLine());
  12.         double at = Double.parseDouble(console.nextLine());
  13.         double h = Double.parseDouble(console.nextLine());
  14.         double tilePrice = Double.parseDouble(console.nextLine());
  15.         double workPrice = Double.parseDouble(console.nextLine());
  16.  
  17.  
  18.         double areaRoom = a * b;
  19.         double areaTile = at * h / 2;
  20.         double tilesNeeded = Math.round((areaRoom / areaTile)) + 5;
  21.         double moneyNeeded = tilesNeeded * tilePrice + workPrice;
  22.  
  23.  
  24.         if (money >= moneyNeeded) {
  25.             money = money - moneyNeeded;
  26.             System.out.printf("%.02f lv left.", money);
  27.         }
  28.         else {
  29.             money = moneyNeeded - money;
  30.             System.out.printf("You'll need %.02f lv more.", money);
  31.         }
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement