Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.text.DecimalFormat;
- /**
- * Created by ChaosFire on 17.11.2017 г.
- */
- public class ResurrectionSecond {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- int phoenixCount = Integer.parseInt(reader.readLine());
- StringBuilder output = new StringBuilder();
- for (int i = 0; i < phoenixCount; i++) {
- double bodyLength = Double.parseDouble(reader.readLine());
- String width = reader.readLine();
- double bodyWidth = Double.parseDouble(width);
- double wingLength = Double.parseDouble(reader.readLine());
- double years = bodyLength * bodyLength * (bodyWidth + 2 * wingLength);
- DecimalFormat decimalFormat = getFormat(width);
- output.append(decimalFormat.format(years)).append(System.lineSeparator());
- }
- reader.close();
- System.out.print(output);
- }
- private static DecimalFormat getFormat(String input) {
- int accuracy;
- String[] data = input.split("\\.");
- if (data.length < 2) {
- return new DecimalFormat("0");
- } else {
- accuracy = data[1].length();
- }
- StringBuilder pattern = new StringBuilder("0.");
- for (int i = 0; i < accuracy; i++) {
- pattern.append("0");
- }
- return new DecimalFormat(pattern.toString());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement