forked from Denisolt/CSCI-160
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreadfromfile.java
More file actions
35 lines (30 loc) · 1.04 KB
/
readfromfile.java
File metadata and controls
35 lines (30 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//Denisolt Shakhbulatov
//31.09.2015
import java.util.Scanner;
import java.io.*;
public class readfromfile
{ public static void main(String[] arg) throws IOException
{
File deposfile = new File("Deposits.txt");
Scanner inputFile = new Scanner(deposfile);
Double SumOfDep=0.0;
Double SumOfWith=0.0;
while (inputFile.hasNext())
{
double number = inputFile.nextDouble();
SumOfDep = SumOfDep + number;
}
inputFile.close();
File withdrawalsfile = new File("Withdrawals.txt");
Scanner withinputFile = new Scanner(withdrawalsfile);
while (withinputFile.hasNext())
{
double number2 = withinputFile.nextDouble();
SumOfWith = SumOfWith + number2;
}
inputFile.close();
System.out.println("The sum of deposits is " + SumOfDep);
System.out.println("The sum of withdrawals is " + SumOfWith);
System.out.println("The sum of deposits is " + SumOfDep);
}
}