Skip to content

Instantly share code, notes, and snippets.

@zachlatta
Created October 10, 2012 01:37
Show Gist options
  • Save zachlatta/3862630 to your computer and use it in GitHub Desktop.
Save zachlatta/3862630 to your computer and use it in GitHub Desktop.
Reading two files and outputting data
// Opens files
BufferedReader deposits = new BufferedReader(FileReader("Deposits.txt");
BufferedReader withdraws = new BufferedReader(FileReader("Withdrawals.txt");
// Reads from files and prints to console
String depositString;
String withdrawString;
double deposit;
double withdraw;
depositString = deposits.readLine();
withdrawString = withdraws.readLine();
while (depositString != null && withdrawString != null)
{
deposit = Double.parseDouble(depositString);
withdraw = Double.paraseDouble(withdrawString);
System.out.prinln("Withdrawals: $" + withdraw + "\nDeposits: $" + deposit);
depositString = deposits.readLine();
withdrawString = withdraws.readLine();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment