forked from angiejones/java-programming
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstantCreditCheck.java
More file actions
61 lines (48 loc) · 1.53 KB
/
Copy pathInstantCreditCheck.java
File metadata and controls
61 lines (48 loc) · 1.53 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
package chapter5;
import java.util.Scanner;
/*
* VARIABLE SCOPE
* Write an ‘instant credit check’ program that approves
* anyone who makes more than $25,000 and has a credit score
* of 700 or better. Reject all others.
*/
public class InstantCreditCheck {
static int requiredSalary = 25000;
static int requiredCreditScore = 700;
static Scanner scanner = new Scanner(System.in);
public static void main(String args[]){
double salary = getSalary();
int creditScore = getCreditScore();
scanner.close();
//Check if the user is qualified
boolean qualified = isUserQualified(creditScore, salary);
//Notify the user
notifyUser(qualified);
}
public static double getSalary(){
System.out.println("Enter your salary:");
double salary = scanner.nextDouble();
return salary;
}
public static int getCreditScore(){
System.out.println("Enter your credit score:");
int creditScore = scanner.nextInt();
return creditScore;
}
public static boolean isUserQualified(int creditScore, double salary){
if(creditScore >= requiredCreditScore && salary >= requiredSalary){
return true;
}
else{
return false;
}
}
public static void notifyUser(boolean isQualified){
if(isQualified){
System.out.println("Congrats! You've been approved.");
}
else{
System.out.println("Sorry. You've been declined");
}
}
}