Sorry, I don't know what the "other two" are. Can you post the current code with comments that shows the problem?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Sorry, I don't know what the "other two" are. Can you post the current code with comments that shows the problem?
If you don't understand my answer, don't ignore it, ask a question.
2. i need to read in all the ints on the lines in the file and store them in the 2d array (8 lines) (10 ints)(4 strings)
3. i need to change the strings at the end of the line and store them in the 2d array
these are what i need to do
Does this mean you are starting over with the program?
What are the steps the new program needs to take to
read in the first part of the lines and save the numbers in one array
and then read the rest of the line and save it in another array?
Can you give an example of where the data from one line will go in the arrays?
Here is a line:
5,5,5,6,5,8,9,5,6,8, good, very good, excellent, good
How will the code put the first part into one array and the second part into another array?
Do all the lines have the same count of numbers and Strings?
If you don't understand my answer, don't ignore it, ask a question.
yeah i have to read in the line in the array testMarks[add][the line of ints and converted ints]
- in the add bit is the line that it is in as it is being stored
if u know what i mean , but they have to be stored in the same 2d array
yh each has 10 ints then 4 strings that have be converted using the switch statement
Do you have code for the new program? The old code doesn't do what you want.
The new program needs a second array to hold the Stringsbut they have to be stored in the same 2d array
If you don't understand my answer, don't ignore it, ask a question.
i have to change the strings into ints via the switch statement i dont wana store the strings themselves
Please explain what the problems are.
The current code does not do what you want. It needs to be rewritten to do the things you want:
1). read in all the ints on the lines in the file and store them in the 2d array
2) change the strings at the end of the line and store them in the 2d array
If you don't understand my answer, don't ignore it, ask a question.
thats what i want it to do , so what do i need to do in that method to ensure that works ??
Start by designing what the method should do. Make a list of the steps(simple steps) that the code needs to do.what do i need to do in that method to ensure that works
When you get a good design, then try coding it in small steps, with testing of each step and printing out the results of each step. When one step is working, add the code for the next step and repeat the process.
If you don't understand my answer, don't ignore it, ask a question.
its just in the for loops the start of the method is what i want so thats find its what happens in the for loops thats the problem
The code needs to be redone. You need a new design and new code.
If you don't understand my answer, don't ignore it, ask a question.
how would i just change the end of the line and store the ints that have been converted ?
Here's a start on the design:
init file for scanning
begin loop to read lines from file
read a line from file and print it for debug
1). read in all the ints on the lines in the file and store them in the 2d array
init scanner to delimit tokens in line
begin loop to scan the line
begin loop to read numbers from line
read next number
store number in array
end loop reading numbers
2) change the strings at the end of the line and store them in the 2d array
begin loop to read strings from end of line
read string and print for debug
convert string
store results in array
end loop reading strings from line
end loop to scan a line
end loop to read lines from file
If you don't understand my answer, don't ignore it, ask a question.
is that part one > for(int add=0; add<responces; add++)
{
for (int columns =0; columns<10; columns ++){
testMarks[add][columns] = scanner.nextInt();
}
--- Update ---
n how do i read the ints on the line if they are all have commas after them
Use the Scanner class's useDelimiter() method. There was one in the earlier posted code.how do i read the ints on the line if they are all have commas after them
If you don't understand my answer, don't ignore it, ask a question.
testMarks[add][columns + i] = ( scanner2.nextInt(); ) < what would go there to make it not null
What variable is null?
testMarks or scanner2
If you don't understand my answer, don't ignore it, ask a question.