How to make user to input numbers in a specific manner like to take input in 'Matrix Form' in java? Is it possible? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to make user to input numbers in a specific manner like to take input in 'Matrix Form' in java? Is it possible?

Actually I wrote a program to check that whether a matrix is a 'Square Matrix ' or not. I wanted that the user must give a matrix of order 3*3 and after each input on pressing ' Enter ' cursor will leave space and then moves to take next input without changing line. When the 3rd input of first row is given ( i.e. 1,3) then on pressing 'Enter' it moves to the next line .The process should continue till 3*3 order of matrix is satisfied. On giving the last number (i.e. 3,3) and then on pressing 'Enter' it should give the output (I.e. whether a matrix is a square matrix or not). Is it possible to do so? If no, then please suggest a better alternative. Please give answer in regard for java language ( because currently I am learning java). Also provide an effective version to check 'Square Matrix'. Thank you!!!

2nd Sep 2018, 4:04 AM
Manu Pandey
Manu Pandey - avatar
3 Answers
+ 2
for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { a[i][j]=new Scanner(System.in).nextInt(); } System.out.println(); }
3rd Sep 2018, 12:36 PM
Aarav Raj
Aarav Raj - avatar
+ 1
first input and store and after print array
3rd Sep 2018, 12:36 PM
Aarav Raj
Aarav Raj - avatar
0
take it and assign it to those rows n cols yourself.
2nd Sep 2018, 10:30 AM
Otumian Empire
Otumian Empire - avatar