Revenue.txt :
Excel IT;50000;55000;65000;60000;54600;47800;67000;55000;58900;54000;60000;63400 Excel Energy;150000; 255000;265000;260000;354600;347800;467000;355OO0;4 58900;4 54OOO;46OOO0;4634O0 Excel Edu;55000;65000;75000;70000;64600;57800;77000;65000; 68900;64000; 68000; 65400 Excel Land;250000;255000;365000;360000;454600;447800;567000; 555000; 658900;654000; 60000;763400
Java Code:
import java.io.*;
import java.util.*;
public class ExcelGroup {
/**
* @param args
*/
public static void main(String[] args) throws IOException{
// TODO Auto-generated method stub
File Rev = new File("Revenue.txt");
Scanner inRev = new Scanner(Rev);
String read = null;
String name = null;
double[] revenue = new double[12];
int i = 0;
File outRev = new File("FirstHalfYear.txt");
PrintWriter half = new PrintWriter(outRev);
while(inRev.hasNext()){
read = inRev.nextLine();
StringTokenizer st = new StringTokenizer(read,";");
System.out.print(st.nextToken());
name = st.nextToken();
System.out.print(st.nextToken());
revenue[i] = Double.parseDouble(st.nextToken());
half.print(revenue[i] + " ");
i++;
}
inRev.close();
half.close();
}
}
Additional info, I need to store the number into an array of size 12 excluding the name.

New Topic/Question
Reply



MultiQuote



|