Hello KucerakJM,
I have attempted to implement the array solution and was able to gather the data in a (String) line of text. My problem is that I don't know how to use substring or split to obtain elements in that line of data. I need to retrieve the account number and total amounts (which will be calculated) in arraylists because these values (customers and total amount of total orders) is subject to change. Here is my updated code, no errors.
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
public class spInputOutput {
public static PrintWriter outputStream;
public static void main(String[] args) throws IOException
{
readData();
}
public static void readData() throws IOException
{
double monthlyBase = 20;
double amountDue = 0;
double time = 0.00;
ArrayList<Double> amtDue = new ArrayList<Double>();
ArrayList<String> accts = new ArrayList<String>();
ArrayList<String> fileCont = new ArrayList<String>();
double daytimeCall = 0.12; /*per minute for calls that started between 8:00 AM and 10:00PM,
inclusive $0.05 per minute all other times*/
FileReader fr = new FileReader("input_data.txt");
BufferedReader br = new BufferedReader(fr);
String invoice = "invoice.txt";
try {
outputStream = new PrintWriter(invoice);
}
catch (FileNotFoundException e) {
e.printStackTrace();
}
outputStream.println("Invoice");
outputStream.println("**********");
outputStream.println("");
outputStream.println("Account");
for(int i=0; i<5; i++)
{
outputStream.println(accts);
}
outputStream.println("Amount Due");
for(int i=0; i<5; i++)
{
outputStream.println("20.20\n");
}
outputStream.println("**********");
outputStream.println("Total");
outputStream.close();
String text = "";
String line = br.readLine();
String[] a = new String[10];
//The values for this for loop were used to see if my program would still run
for(int i = 0; i<a.length ; i++)
{
a[i] = br.readLine();
//a[i].split("");
}
System.out.println(a[1]);
System.out.println(a[2]);
while(line != null)
{
text += line;
line = br.readLine();
fileCont.add(line);
//System.out.println(text);
}
System.out.println("Invoice File Created");
}
}
My objectives are currently to;
1. Format the input document so that the account numbers can be obtained and re-presented in the output file
2. Calculate the total amount with the start time and duration considered (I still must derive this algorithm)
3. Print these values to the invoice file
Thanks again for your help so far