473,385 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Need major help on FileReader/Array/Matrix Program

1
I've been researching so much about arrays and matrices and such, but it hasn't helped me at all on my program. Everything is either over my head or doesn't help with the specific program I have to code. All I've been able to do so far is to get the file read in.

Program: Write a code that will read in a text file (which contains a list of words and their definitions, separated by a hyphen). The data read in will be stored into an array. Then store the array into a matrix, and output the matrix. Be sure to print out a hyphen to separate the words and their definitions.

Expand|Select|Wrap|Line Numbers
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class oops
  5. {
  6.     public static void main (String args[]) throws IOException
  7.     {
  8.         String[] y = new String[2];
  9.         Scanner in = new Scanner (new FileReader ("oopswords.txt"));
  10.         while (in.hasNext())
  11.         {
  12.             String text = null;
  13.             text = in.nextLine();
  14.             y = text.split("-");
  15.         }
  16.  
  17.     }
  18. }
How would I go about putting the data read in into an array? I'm not sure if the y=text.split("-") is correct, or at least in the right spot. Do I have to make a for loop to input the data into an array, and if so, does the for loop go inside or out of the while loop? I'm assuming that two arrays will be used: one for the words and one for the definitions, but again, I'm not that certain. Then how do I write the array(s) into a matrix to print it out?
Feb 15 '08 #1
2 2136
r035198x
13,262 8TB
...
How would I go about putting the data read in into an array? ...
The split method actually returns an array ..
Feb 15 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Gattaca | last post by:
I would like to create a matrix of integers by allocating memory dynamically (malloc or calloc) because i and j are defined during execution of the program. I have got not problem to do this in...
9
by: sangeetha | last post by:
Hello, Is there any performance difference in using of the following two declaration? int (*ptr); //Array of 10 int pointers int *ptr; // pointer-to-array of 10. Regards, Sangeetha.
1
by: raylegendkiller | last post by:
NEED TO MAKE A PROGRAM which computes the current value of the vectors {x} based on the following forward iterations: this >>> {x}(n+1) = {x}(n), n = 0,1,2, ... ,8,9. In other...
4
by: flash | last post by:
I need to complete derived class and main class: derived class should have data member: major(string), grades: an array of integrs (size 5). it should have methods to: 1-set and get the major....
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
1
by: Peterwkc | last post by:
Hello all expert, i have two program which make me desperate bu after i have noticed the forum, my future is become brightness back. By the way, my problem is like this i the first program was...
1
by: shadowofanubis66 | last post by:
Basically, the project I'm working on this week is to make a school lunch menu with a GUI, when the person types in a day, the menu for that day shows up. We have two files, ones a day off text file...
0
by: yjh0914 | last post by:
hi guys! so im basically editting my post i made earlier as it wznt as specific.. i have to make a program that basically ranks students by their cumulative gpa. the student's info is on a csv file...
3
by: rudra | last post by:
dear all, being a starter with C++, i am getting a problem with array. i have a (say),NxN array in a file, from which i have to read the nXn (n<N, obviously) chunk, and with each iteration, the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.