-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCreditScoreModule
125 lines (113 loc) · 4 KB
/
CreditScoreModule
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Credit Score Calculator</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
}
.container {
max-width: 500px;
margin: 50px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
.input-container {
margin-bottom: 15px;
}
label {
display: block;
font-weight: bold;
}
input {
width: 100%;
padding: 8px;
border-radius: 5px;
border: 1px solid #ccc;
}
button {
padding: 10px 20px;
background-color: #4caf50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
button:hover {
background-color: #45a049;
}
#result {
margin-top: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<div class="container">
<h1>Credit Score Calculator</h1>
<div class="input-container">
<label for="income">Annual Income ($):</label>
<input type="number" id="income" min="0">
</div>
<div class="input-container">
<label for="debt">Total Debt ($):</label>
<input type="number" id="debt" min="0">
</div>
<div class="input-container">
<label for="payment-history">Payment History (0-100):</label>
<input type="number" id="payment-history" min="0" max="100">
</div>
<div class="input-container">
<label for="credit-utilization">Credit Utilization (0-100):</label>
<input type="number" id="credit-utilization" min="0" max="100">
</div>
<div class="input-container">
<label for="credit-age">Credit Age (years):</label>
<input type="number" id="credit-age" min="0">
</div>
<button id="calculate">Calculate</button>
<div id="result"></div>
</div>
<script>
document.getElementById('calculate').addEventListener('click', function() {
const income = parseFloat(document.getElementById('income').value);
const debt = parseFloat(document.getElementById('debt').value);
const paymentHistory = parseInt(document.getElementById('payment-history').value);
const creditUtilization = parseInt(document.getElementById('credit-utilization').value);
const creditAge = parseInt(document.getElementById('credit-age').value);
// Calculate credit score
let creditScore = 700; // Default score
// Negative factors
if (paymentHistory < 70) {
creditScore -= 50; // Poor payment history
}
if (creditUtilization > 30) {
creditScore -= 30; // High credit utilization
}
if (creditAge < 1) {
creditScore -= 20; // Short credit age
}
if (debt > income * 0.5) {
creditScore -= 100; // High debt-to-income ratio
}
// Positive factors
if (paymentHistory >= 90) {
creditScore += 30; // Excellent payment history
}
if (creditUtilization <= 10) {
creditScore += 20; // Low credit utilization
}
if (creditAge >= 5) {
creditScore += 40; // Long credit age
}
// Display result
document.getElementById('result').innerHTML = Your credit score is: ${creditScore};
});
</script>
</body>
</html>