Thanks
-Ty
Expand|Select|Wrap|Line Numbers
- import java.util.Scanner;
- import java.io.IOException;
- public class ScannerDemoforNetbeans
- {
- public static void main (String [] args)throws IOException
- {
- int x = 55;
- Scanner s = new Scanner (System.in);
- System.out.println ("What is your name?");
- String name = s.nextLine ();
- Scanner a = new Scanner (System.in);
- System.out.println ("welcome, " + name + ", would you like to play a game with me?");
- String answer = a.nextLine ();
- if (answer.equalsIgnoreCase("yes"))
- {
- System.out.println ("Will you Give me some numbers so I can make a matrix with them?");
- Scanner nextanswer = new Scanner (System.in);
- String q = nextanswer.nextLine();
- }
- if (answer.equalsIgnoreCase("yes"))
- {
- System.out.println ("YAY!!! okay, How many matricies do you want");
- Scanner i = new Scanner (System.in);
- int number1;
- number1 = i.nextInt();
- System.out.println(number1);
- System.out.println ("Okay, you got it! How many rows do you want");
- Scanner rc= new Scanner (System.in);
- public static rows;
- rows= rc.nextInt();
- System.out.println ("How many columns do you want?");
- Scanner c = new Scanner (System.in);
- public static columns;
- columns = c.nextInt();
- System.out.println ("Rows" + rows);
- System.out.println ("Columns:" + columns);
- }
- // }
- // public static void createarray (String [] args)
- // {
- int matWidth = ScannerDemoforNetbeans.columns;
- int matHeight = ScannerDemoforNetbeans.rows;
- int maxCellValue = 70;
- int [][] mat1 = new int [matHeight][matWidth];
- int [][] mat2 = new int [matHeight][matWidth];
- int [][] sum = new int [matHeight][matWidth];
- for (int i=0; i<matHeight; ++i)
- {
- for (int j=0; j<matWidth; ++j)
- {
- java.util.Random r = new java.util.Random();
- mat1 [i][j]= r.nextInt (maxCellValue);
- mat2 [i][j] = r.nextInt (maxCellValue);
- }
- }
- print2Darray (mat1);
- System.out.println ();
- print2Darray (mat2);
- for (int i=0; i<matHeight; ++i)
- {
- for (int j=0; j<matWidth; ++j)
- {
- sum [i][j]= mat1 [i][j] + mat2 [i][j];
- }
- }
- System.out.println ();
- print2Darray (sum);
- }
- public static void print2Darray (int[][]arr)
- {
- for (int [] i : arr)
- {
- for (int j : i)
- {
- System.out.print (j + " ");
- }
- System.out.println();
- }
- System.out.println ();
- }
- }