Skip to main content

Storing data from a file that includes ints and strings in the file on the lines

Please note these forums are being decommissioned and use the new and improved forums at
No replies
Joined: 2013-02-24

Hey I need help on a java project that i am doing
there are a couple of things that im not sure of and thar i need help with
1. i need to be able to read the ints on a line (but they are followed by commas)
2 . to be able to store these ints
3. change the strings at the end of the line into ints
4 . store these ints as well in the same 2d array as the first ints

Thank You in advance !!!

this is my code:
String now = scanner.nextLine();
Scanner scanner2 = new Scanner(now);
scanner2.useDelimiter("[ ]*(,)[ ]*");
for(int add=0; add

for (int columns =0; columns<10; columns ++)
testMarks[add][columns] = scanner2.nextInt();
for(int i =0; i<4; i++)
case "excellent": num=5; break;
case "very good": num=4; break;
case "good": num=3; break;
case "average": num=2; break;
case "poor": num=1; break;
default : num=0; break;

testMarks[add][columns + i] = scanner2.nextInt();


data2.txt481 bytes