What is wrong with my code? use the IN300_Dataset2.txt file (https://kapextmediassl-a.akamaihd.net/IST/IN300/IN300_1905A/IN300_Dataset2.txt) Write a Java program that: A. Reads the text file. B. Using that data, create a two-dimensional array that is 2,500 rows by 100 columns. C. Slice the two-dimensional array using a starting column index of 2 and an ending column index of 5. Print the results of the arrays and slice.   import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.io.File; import java.util.Scanner; import java.lang.Float; public class Main { public static void main(String args[]) { File file = new File("/Users/ahmedgasim/Desktop/IN300_Dataset2.txt"); String line; ArrayList data = new ArrayList(); try (BufferedReader br = new BufferedReader(new FileReader(file))) { while((line = br.readLine())) ! = null) { data.add(Long.parseLong(line)); } } catch (Exception e) { System.out.println(e); } int sRows = 2500; int sCols = 100; int entry = 0; long [][] array2D = new long[Rows][Cols]; for (int r = 0; r < Rows; r++) System.out.print("["); for (int c = 0; c < Cols; c++) { array2D[r][c] = data.get(entry++); System.out.print(array2D[r][c] + ""); } System.out.print("]"); } int sRows = 2500; int sCols = 4; float [][] sliced = new float[sRows][sCols]; for(int sr =0; sr < sRows; sr++) { for (int sc = 0; sc < sCols; sc++) { sliced[sr][sc] = array2D[sr][sc]; } } for (int i = 0; i < sliced.lenght; i++){ for (int j = 0; j < sliced[j].lenght; j++) { System.out.print(sliced[i][j] + ""); } System.out.println(); } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

What is wrong with my code?

use the IN300_Dataset2.txt file (https://kapextmediassl-a.akamaihd.net/IST/IN300/IN300_1905A/IN300_Dataset2.txt)

Write a Java program that:

A. Reads the text file.

B. Using that data, create a two-dimensional array that is 2,500 rows by 100 columns.

C. Slice the two-dimensional array using a starting column index of 2 and an ending column index of 5. Print the results of the arrays and slice.

 

import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.io.File; import java.util.Scanner; import java.lang.Float; public class Main { public static void main(String args[]) { File file = new File("/Users/ahmedgasim/Desktop/IN300_Dataset2.txt"); String line; ArrayList<Long> data = new ArrayList<Long>(); try (BufferedReader br = new BufferedReader(new FileReader(file))) { while((line = br.readLine())) ! = null) { data.add(Long.parseLong(line)); } } catch (Exception e) { System.out.println(e); } int sRows = 2500; int sCols = 100; int entry = 0; long [][] array2D = new long[Rows][Cols]; for (int r = 0; r < Rows; r++) System.out.print("["); for (int c = 0; c < Cols; c++) { array2D[r][c] = data.get(entry++); System.out.print(array2D[r][c] + ""); } System.out.print("]"); } int sRows = 2500; int sCols = 4; float [][] sliced = new float[sRows][sCols]; for(int sr =0; sr < sRows; sr++) { for (int sc = 0; sc < sCols; sc++) { sliced[sr][sc] = array2D[sr][sc]; } } for (int i = 0; i < sliced.lenght; i++){ for (int j = 0; j < sliced[j].lenght; j++) { System.out.print(sliced[i][j] + ""); } System.out.println(); } } 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY