-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMain.java
More file actions
78 lines (75 loc) · 3.01 KB
/
Copy pathMain.java
File metadata and controls
78 lines (75 loc) · 3.01 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
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
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner file = null;
float numBuy = 0;
float numNoBuyLVT = 0;
float numNoBuyDTI = 0;
float numNoBuyFEDTI = 0;
float numNoBuyCreditScore = 0;
float numNoBuyMortgagePortionHigh = 0;
float numCustomers = 0;
try {
file = new Scanner(new File("HackUTD-2023-HomeBuyerInfo.txt"));
file.nextLine();
HashMap<Integer, Person> homeOwnerMap = new HashMap<>();
PrintWriter write = new PrintWriter("output.txt");
while (file.hasNext()) {
numCustomers++;
int id = file.nextInt();
int monthlyIncome = file.nextInt();
int creditCardPayment = file.nextInt();
int carPayment = file.nextInt();
int studentLoanPayments = file.nextInt();
int appraisedValue = file.nextInt();
float downPayment = file.nextFloat();
float loanPayment = file.nextFloat();
float monthlyMortgagePayment = file.nextFloat();
int creditScore = file.nextInt();
Person homeOwner = new Person(monthlyIncome, creditCardPayment, carPayment, studentLoanPayments, appraisedValue, downPayment, loanPayment, monthlyMortgagePayment, creditScore);
homeOwnerMap.put(id, homeOwner);
if (homeOwner.buyHouse) {
numBuy++;
} else {
if (homeOwner.denialReason[0]) {
numNoBuyLVT++;
}
if (homeOwner.denialReason[1]) {
numNoBuyDTI++;
}
if (homeOwner.denialReason[2]) {
numNoBuyFEDTI++;
}
if (homeOwner.denialReason[3]) {
numNoBuyCreditScore++;
}
if (homeOwner.denialReason[4]) {
numNoBuyMortgagePortionHigh++;
}
}
write.print("Customer ID number: ");
write.println(id);
if(homeOwner.buyHouse){
write.println("This customer is ready to buy a home");
}
else {
write.println("This customer is not ready to buy a home.");
write.print("Suggestions for Improvement: ");
write.println(homeOwner.whatToDo);
}
write.println("---------------------------------");
if (file.hasNextLine()) {
file.nextLine();
}
}
write.close();
} catch (FileNotFoundException e) {
System.out.println("File not found");
}
}
}