Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Project: Exam_24_April_2016 - created by borkins on 2017-05-14.
- */
- import java.text.DecimalFormat;
- import java.util.Scanner;
- public class _01_RepairingTiles
- {
- public static void main(String[] args)
- {
- Scanner console = new Scanner(System.in);
- int areaLength = Integer.parseInt(console.nextLine());
- double tileWidth = Double.parseDouble(console.nextLine());
- double tileLength = Double.parseDouble(console.nextLine());
- int benchWidth = Integer.parseInt(console.nextLine());
- int benchLength = Integer.parseInt(console.nextLine());
- int areaToFill = (areaLength * areaLength) - (benchWidth * benchLength);
- double tilesArea = tileWidth * tileLength;
- double tilesNeeded = areaToFill / tilesArea;
- double timeMin = tilesNeeded * 0.2;
- System.out.println(doubleToCSharpDouble(tilesNeeded));
- System.out.println(doubleToCSharpDouble(timeMin));
- }
- public static String doubleToCSharpDouble(double number)
- {
- StringBuilder sb = new StringBuilder();
- String str = "" + number;
- int len = (str.length() > 16) ? 16 : str.length();
- for (int i = 0; i < len; i++)
- {
- if (str.charAt(i) != '.') {
- sb.append("#");
- }
- else {
- sb.append(".");
- }
- }
- return new DecimalFormat(sb.toString()).format(number);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment