Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigDecimal;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- /**
- * Created by todor on 16.02.2017 г..
- */
- public class Dummy {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int squareAreaSideSize = Integer.parseInt(scan.nextLine());
- double tileWidth = Double.parseDouble(scan.nextLine());
- double tileHeight = Double.parseDouble(scan.nextLine());
- int benchWidth = Integer.parseInt(scan.nextLine());
- int benchHeight = Integer.parseInt(scan.nextLine());
- BigDecimal tileTime = new BigDecimal("0.2");
- double benchArea = benchWidth * benchHeight;
- BigDecimal squareAreaWithoutBench = new BigDecimal(String.valueOf(squareAreaSideSize * squareAreaSideSize - benchArea));
- BigDecimal singleTileArea = new BigDecimal(String.valueOf(tileWidth * tileHeight));
- DecimalFormat df = new DecimalFormat("#.############");
- BigDecimal talesNeeded = squareAreaWithoutBench.divide(singleTileArea, 30, BigDecimal.ROUND_HALF_UP);
- int talesNeededRoundTo = 15 - (talesNeeded.toPlainString().indexOf('.'));
- BigDecimal finishTime = talesNeeded.multiply(tileTime);
- int finishTimeRoundTo = 15 - (finishTime.toPlainString().indexOf('.'));
- talesNeeded = talesNeeded.setScale(talesNeededRoundTo, BigDecimal.ROUND_HALF_UP);
- finishTime = finishTime.setScale(finishTimeRoundTo, BigDecimal.ROUND_HALF_UP);
- System.out.println(df.format(talesNeeded));
- System.out.println(df.format(finishTime));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement