Question: Use the method { public static boolean is ConsecutiveFour(int[][] values) } to test whether two dimensional array has four consecutive numbers of the same value

Use the method { public static boolean is ConsecutiveFour(int[][] values) } to test whether two dimensional array has four consecutive numbers of the same value , either horizontally , vertically , or diagonally.(java please)

1-nstead of having your program get input from the keyboard make it read the data from files (num1.txt, num2.txt,num3.txt,num4.txt,num5.txt,num6.txt)

example : num6.txt

0 1 0 3 1 6 1

0 1 6 8 6 0 1

5 5 2 2 8 2 9

6 4 2 2 2 2 1

1 5 6 2 4 0 7

3 4 3 2 4 0 7

num5.txt

0 0 0 0 1 6 1

0 1 6 8 6 1 1

9 6 2 1 1 2 2

6 9 6 1 1 9 2

1 3 9 1 4 0 2

3 3 3 9 4 0 2

2-Pass the name of the file into your program as a command line argument...Look at CmdLine.java for an example of this!

import java.util.*;

import java.io.*;

public class Cmdline {

public static void main(String[] args)throws FileNotFoundException{

System.out.println("args[0]is "+args[0]);

Scanner s=new Scanner(new File(args[0]));

while(s.hasNext()){

int x=s.nextInt();

System.out.println("x is "+x);

}

s.close();

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!