Advertisement
DemonCowgirl

Beth's Code

Mar 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.32 KB | None | 0 0
  1.  
  2. import java.io.*; // needed for IO classes (InputStream, OutputStream, Reader)
  3. import java.util.*;
  4. import java.text.*; //to format doubles to only two decimal places
  5.  
  6. public class Project4
  7. {
  8.    private static DecimalFormat df2 = new DecimalFormat("#.##");// to truncate double to two decimal places
  9.    
  10.    public static void main(String[] args)throws Exception{
  11.          
  12.       // variables
  13.      
  14.                    
  15.       try
  16.       {
  17.          FileReader fr = new FileReader("C:\\solution\\DBI_Files\\Project4InData.txt");
  18.          Scanner infile = new Scanner(fr);
  19.          PrintWriter outFile = new PrintWriter("C:\\solution\\DBI_Files\\Project4Out.txt");
  20.          
  21.          // use loop to split text file into string array
  22.          // then convert to integer array        
  23.          while (infile.hasNextLine()){
  24.             String[] stringData = inFile.split(" ");
  25.             int [] numberData = new int[stringData.length];
  26.            
  27.             // use loop to create indexed array of integers
  28.          for(int i = 0; i < numberData.length; i++){
  29.             String numberAsString = stringData[i];
  30.             int loanAmt[0] = Integer.parseInt(numberData[0]);
  31.             int interest[1] = Integer.parseInt(numberData[1]);
  32.             int term[2] = Integer.parseInt(numberData[2]);
  33.             }  
  34.            }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement