• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Java gods?

ChrisCramer247

Platinum Member
I am thourghly confused by this. I am supposed to write a program to read and write off an array. The assignment can be found here if I'm not making much sense: Assignment with a psuedo guide here . Guide. This is what I have so far, I created a token for each but how do I set up this array? We haven't even touched on arrays in class and have to do this so I am COMPLETELY clueless unfortunately.

public class ReadData{
void readData(Inventory[] item)throws IOException{

String line="";

BufferedReader fileInput=new BufferedReader(new FileReader("Sales2.txt"));

//set to receive information by row

for (int row=0;row<5;row++){

line= fileInput.readLine();

StringTokenizer tk = new StringTokenizer(line,",");

String name=tk.nextToken();

String description=tk.nextToken();

String performance=tk.nextToken();

String sales=tk.nextToken();




Am I on the right track or am I completely off? Thanks for the help everyone.

Chris
 
You are on the right track just need to understand what arrays will do.

Inventory[] item is what you should probably be returning not passing into the method.

So if you create an array of Invetory Objects then each time you go through the loop
you would create a new Inventory object, initialize it with the names, prices, etc that you
are getting and return the array of those new objects to the main program. You are close.


If you, or anyone else needs help I provide online java tutoring for a small price.

I also am available for freelance java programming for those in need.

Just PM for more help..
 
Back
Top