Advertisement
Guest User

Untitled

a guest
May 17th, 2022
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.io.File;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args) {
  7.         try {
  8.             Scanner scan = new Scanner(new File("./input.txt"));
  9.             double[][] measure = new double[3][4];
  10.             String[] kind = new String[3];
  11.             int x = 0, y = 0;
  12.             while (scan.hasNextLine()) {
  13.                 for (String item : scan.nextLine().split(" ")) {
  14.                     try {
  15.                         measure[x][y] = Double.parseDouble(item);
  16.                         y++;
  17.                     } catch (Exception e) {
  18.                         kind[x] = item;
  19.                     }
  20.                 }
  21.                 y = 0;
  22.                 x++;
  23.             }
  24.             for (int i = 0; i < measure.length; i++) {
  25.                 for (int j = 0; j < measure[i].length; j++) {
  26.                     System.out.printf("%.1f ", measure[i][j]);
  27.                 }
  28.                 System.out.println(kind[i]);
  29.             }
  30.         } catch (Exception e) {
  31.             System.out.println(e);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement