• Home
  • Blog
  •   In Java: This program should begin by asking the user for the name of a text file containing the data. Then…

  In Java: This program should begin by asking the user for the name of a text file containing the data. Then…

0 comments

 

In Java:

This program should begin by asking the user for the name of a text file containing the data. Then read the data which will be a line containing the dimensions of a 2 dimensional array followed by a 2 dimensional array of ints. Then perform various operations (see the sample interaction below). Then replace the text file with the modified 2 dimensional array (with the file formatted the same way).

 

 

 

 

Sample input.txt file:

3 5

2 3 4 5 10

4 5 2 3 7 –

3 -1 0 1 5

Sample interaction 1:

Next command >

help

Legal commands:

show array

which rows sorted

which cols sorted

increase row i by n i

increase col j by n

quit Next command >

show array 2 3 4 5 10

4 5 2 3 7 –

3 -1 0 1 5

Next command > which rows sorted

Sorted rows: 0, 2

Next command >

which cols sorted

Sorted columns:

Next command > i

ncrease row 2 by 8

Next command >

increase col 4 by 1

Next command >

show array

2 3 4 5 11

4 5 2 3 8

5 7 8 9 14

Next command >

which cols sorted

Sorted columns: 0, 1

Next command > quit

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}