Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.52 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Third {
  4.  
  5.     public static void main(String[] args) {
  6.         int firstNameLength = GetNameLength();
  7.  
  8.         double[][] table = MakeTable(firstNameLength);
  9.  
  10.         System.out.println();
  11.         System.out.println();
  12.  
  13.         GetMinimumValueFromFirstDiagonal(table);
  14.     }
  15.  
  16.     public static double GenerateRandom() {
  17.         return Math.random() * 10;
  18.     }
  19.  
  20.     public static int GetNameLength() {
  21.         String name;
  22.         Scanner scanner = new Scanner(System.in);
  23.  
  24.         do {
  25.             System.out.println("Podaj imie (dluzsze od 4)");
  26.             name = scanner.nextLine();
  27.         }
  28.         while (name.length() < 4);
  29.  
  30.         return name.length();
  31.     }
  32.  
  33.     public static double[][] MakeTable(int size) {
  34.         double[][] table = new double[size][size];
  35.  
  36.         for (int i=0;i<size;i++) {
  37.             for (int j=0;j<size;j++) {
  38.                 table[i][j] = Math.round((Math.random() * 1) * 100.0) / 100.0;
  39.                 System.out.print(table[i][j] + " ");
  40.             }
  41.             System.out.println();
  42.         }
  43.  
  44.         return table;
  45.     }
  46.  
  47.     public static void GetMinimumValueFromFirstDiagonal(double[][] table) {
  48.         double temp = 0;
  49.  
  50.         for (int i=0;i<table.length; i++){
  51.             System.out.print(table[i][i] + " ");
  52.         }
  53.         System.out.println();
  54.         System.out.println();
  55.  
  56.         for (int j=table[0].length -1; j>=0 ;j--) {
  57.             System.out.print(table[j][j] + " ");
  58.         }
  59.     }
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement