-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFinaliseProject.java
81 lines (66 loc) · 2.12 KB
/
FinaliseProject.java
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package l2Task7;
/* Class to generate an invoice if the fee charged is not
* fully paid and display customer details.
*
*/
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class FinaliseProject {
String name;
String telephoneNumber;
String emailAddress;
double feeCharged;
double amountPaid;
//Initiating the Constructor
public FinaliseProject(String name,String telephoneNumber,String emailAddress,String physicalAddress,float feeCharged, float amountPaid) {
this.name = name;
this.telephoneNumber = telephoneNumber;
this.emailAddress = emailAddress;
this.feeCharged = feeCharged;
this.amountPaid = amountPaid;
}
//
public void completedProject(String name, String telephoneNumber,String emailAddress,String physicalAddress,double feeCharged, double amountPaid) {
//
if(amountPaid < feeCharged) {
double outstandingAmount = feeCharged - amountPaid;
try {
FileWriter writeText = new FileWriter("CompletedProject.txt");
PrintWriter printWriter = new PrintWriter(writeText);
printWriter.printf("Name : %s\n"
+ "Telephone Number : %s\n"
+ "Email Address : %s\n"
+ "Outstanding Amount : %s\n",name,telephoneNumber,emailAddress,physicalAddress,outstandingAmount);
writeText.close();
System.out.println("\n INVOICE:\n");
} catch(IOException e) {
System.out.println("An error has occured");
e.printStackTrace();
}
//
try {
FileReader projectFile = new FileReader("CompletedProject.txt");
BufferedReader projectReader = new BufferedReader(projectFile);
String line = "";
line = projectReader.readLine();
while(line != null) {
System.out.println(line);
line = projectReader.readLine();
}
projectReader.close();
}catch(Exception ex) {
System.out.println("Error: " + ex);
}
}
//
else if(amountPaid == feeCharged) {
System.out.println("Amount is Paid in Full.");
}
else {
System.out.println("Inconsistent amounts entered");
}
}
}