Results 1 to 2 of 2
- 12-05-2011, 05:36 AM #1Member
- Join Date
- Dec 2011
- Rep Power
Really need some help guys! (reading files and passing arrays)
I'm somewhat new to java, and I'm taking classes but I'm really starting to take an interest in it, so expect more questions from me!
But a problem I got for my current class really has me stumped.
We're using eclipse
I do not understand how to import a file into eclipse and have it read, and for that matter, what eclipse will "see" when it is read.
I need to make 3 arrays out of a data file that looks like this in notepad (a one dimensional String array, a two dimensional double array, and a single dimensional double array)
I tried to explain this so i can just get the concepts and leave, but i've tried for the last 30 minutes and can't
So i'm going to post the whole prompt, I hope that is ok and not thought of as dishonest?
here's one of the data files (concert1.dat):
Telletubbies, 1, 3, 12.50
Cher, 2, 12, 10.03
Telletubbies, 3, 2, 5.6
Cher, 1, 1, 50.21
Cher, 0, 4, 30.11
Cher, 2, 5, 10.03
Telletubbies, 3, 1, 5.6
Telletubbies, 2, 4, 7.89
The concert has ended and now the accountant needs to figure out if the money collected will offset the cost to put on the two concerts. This is a new project that is separate from your past work.
This program will produce statistics and accounting information for the concerts. You will create a class Account to calculate statistical and accounting information. Account consists of at least the following: a double two dimensional array to hold the individual concert sales, a double single dimensional array to hold the seat prices, a String array to hold the concert names and an int array to hold the number of transaction in the array from the file. In order to test your system, I recommend you write one Account method at a time and then test each method. Here are the methods you should create – averageTicketPrice, grossSales, medianTicketPrice [you will need to order the array], ticketTotal [number of tickets sold], maxTicketOrder, minTicketOrder and two additional get/set method pairs. The methods should read the arrays and supply the requested information.
The AccountSystem class is the driver for Account. Request the file name from the user that contains the ticket sales for every concert at a single venue. Two example files – concert1.dat and concert2.dat are included with the project to test your program. You will only process one file at a time and the application will only use one file. If someone wanted to use the second file, the program would need to be restarted.
Create a readFile method that is part of the main driver file, sending the contents of the file in a single array along with the filename entered by the user. readFile returns the filename and the number of values read from the file into the array in String. The AccountSystem’s main prints the results.
Use the Accounts class, to process the array containing the ticket sales information. The format of the data is [concert (String), tickettype (int), numberoftickets (int), individualseatcost (int)] – ie Telletubbies, 1, 3, 12.50.
Add the following exception handlers – make sure the file exists, prevent divide by zero errors and make catch index out of bounds errors.
Last edited by el poyo loco; 12-05-2011 at 05:46 AM.
- 12-05-2011, 05:49 AM #2Senior Member
- Join Date
- Oct 2011
- Rep Power
Re: Really need some help guys! (reading files and passing arrays)
It really doesn't have anything to do with what eclipse will see. Here are links for 2 good video tutorial: Java Video Tutorials: Learn Java the easy way!, Java Video Tutorials: Learn Java the easy way!
Here's a link for a tutorial on passing arrays as parameters: Beginning Java - Unit 6 Arrays - Arrays and Methods
Hope it helps!
- By boys21 in forum New To JavaReplies: 1Last Post: 11-20-2011, 11:29 PM
- By toppcon in forum New To JavaReplies: 21Last Post: 07-28-2011, 06:05 AM
- By TopNFalvors in forum New To JavaReplies: 0Last Post: 03-17-2011, 05:19 PM
- By NeverHide in forum New To JavaReplies: 5Last Post: 05-20-2010, 09:18 PM
- By pradeesh in forum New To JavaReplies: 1Last Post: 01-16-2009, 11:14 AM