Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java 2 Task: Write a Java program to solve the following problem using 2-dim arrays. Given a 2-dim array (matrix) containing only 1 or 0

java
image text in transcribed
image text in transcribed
2 Task: Write a Java program to solve the following problem using 2-dim arrays. Given a 2-dim array (matrix) containing only 1 or 0 values, determine if there are 2 rows 1 and 22 so that -1 is the same as 12 flipped. For example, if z holds the values o 1 1 0 0 1, then -2 should hold the values 1 0 0 1 1 0 Program requirements Have (at least) the following methods: 1. A method named getInt to get input a valid integer. The method is used to test for type errors in input 2. A method named interand to fill the way with random values: the elements of the way should be random integers (0 or 1> 3. A method named print to print the elements of the array Use printe. Also, get the format from the sample output (row index in front of cach row) 4. A method to find flipped rows (design decisions?) All methods processing the array should take as input parameters the array (une length). Make sure that all methods are reusable! Write a driver program to call these methods and get output similar to the simple output below (use a sentinel-controlled loop) Work with dynamic arrays and get input from the user the row size/column size. Make sure you handle input validation . . SAMPLE OUTPUT: Do you want to start A/N : Y How many TOMS 423rt 23 Not an integer! Try again! How many towa1 6.78 Not an integer! Try again! How many Tow: 8 How many columns The strik 151 10) 0 11 1 [2) 2 1 2 143 0 0 15 1 1 1 16) 1 2 0 [72 0 Rows index and 1 are flipped. Rows Index 0 and 6 are flipped Row index) and 4 are flipped ROWS index: 3 and are flipped Rows index 4 and 5 are flipped Rows index and are apped. 13) RO Do you want to continua (Y/ NY How many row: 3 How many columns Evet Not an Integer TV and How many columns The matrix -Arrays 2 / 3 67% I sentinel-comtrolled loop) Work with dynamic arrays and get input from the user the row size column size. Make sure you handle imput validation SAMPLE OUTPUT: Do you want to start (Y/N): Y How many EOS 423t23 Not an integer! Try again! How many TOWSE 6.78 Not an integer! Try again! How many row: 8 How many columns 4 The matrix ist 10) 0 0 a 1 (1) 1 1 1 0 [2] 1 1 0 [3] 1 1 0 1 [4] 0 2 0 151 1 1 0 1 16 1 1 1 0 0 1 0 ROWS Index and 1 are flipped. Rows Index and are flipped. Row Index ) and 4 are flipped. Hos index 3 and 7 are fined. Row index 4 and are flipped. Rows index 5 and 7 are flipped. Do you want to contine (Y/N 1 How many TowS: 3 Hummy Luwu integer! Try again! How many count the matrix ID D 1 23 2 1 Slipped Tous in this matrix. Dant to contTMEY How many rava safeat tot an integer teygio How many you? How many as tggt neger! Try again! How many com The 102 11 IS tape Indekar Tipped http/ 82 W 20

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

Students also viewed these Databases questions

Question

What are the differences between hard and soft variants of HRM?

Answered: 1 week ago