Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Third {
- public static void main(String[] args) {
- int firstNameLength = GetNameLength();
- double[][] table = MakeTable(firstNameLength);
- System.out.println();
- System.out.println();
- GetMinimumValueFromFirstDiagonal(table);
- }
- public static double GenerateRandom() {
- return Math.random() * 10;
- }
- public static int GetNameLength() {
- String name;
- Scanner scanner = new Scanner(System.in);
- do {
- System.out.println("Podaj imie (dluzsze od 4)");
- name = scanner.nextLine();
- }
- while (name.length() < 4);
- return name.length();
- }
- public static double[][] MakeTable(int size) {
- double[][] table = new double[size][size];
- for (int i=0;i<size;i++) {
- for (int j=0;j<size;j++) {
- table[i][j] = Math.round((Math.random() * 1) * 100.0) / 100.0;
- System.out.print(table[i][j] + " ");
- }
- System.out.println();
- }
- return table;
- }
- public static void GetMinimumValueFromFirstDiagonal(double[][] table) {
- double temp = 0;
- for (int i=0;i<table.length; i++){
- System.out.print(table[i][i] + " ");
- }
- System.out.println();
- System.out.println();
- for (int j=table[0].length -1; j>=0 ;j--) {
- System.out.print(table[j][j] + " ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement