Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Keith-sys committed Feb 8, 2023
1 parent b0d4e49 commit 2de6be0
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main-Class: org.keith.Main
3 changes: 1 addition & 2 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ The containing feature are:
## Build Instructions
Step 1) Build source files
```
javac src/main/java/org/keith/core/*.java src/main/java/org/keith/menu/*.java src/main/java/org/keith/menu/enums/*.java src/main/java/org/keith/*.java -d bin
javac -cp "<lombok_path>" src/main/java/org/keith/core/*.java src/main/java/org/keith/menu/*.java src/main/java/org/keith/menu/enums/*.java src/main/java/org/keith/*.java -d bin
```

Step 2) Run the program
```
cd bin
Expand Down
Binary file removed bin/org/keith/Main.class
Binary file not shown.
Binary file removed bin/org/keith/core/Amortization.class
Binary file not shown.
Binary file removed bin/org/keith/core/LoanDetails.class
Binary file not shown.
Binary file removed bin/org/keith/core/LoanInput.class
Binary file not shown.
Binary file removed bin/org/keith/core/Scheduler.class
Binary file not shown.
Binary file removed bin/org/keith/core/SingletonScanner.class
Binary file not shown.
Binary file removed bin/org/keith/menu/Menu$1.class
Binary file not shown.
Binary file removed bin/org/keith/menu/Menu.class
Binary file not shown.
Binary file removed bin/org/keith/menu/enums/MenuCommand.class
Binary file not shown.
35 changes: 19 additions & 16 deletions src/main/java/org/keith/core/LoanInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,24 @@ public class LoanInput{
Scanner scanner = singletonScanner.getScanner();

// Check Terms based on the type of loan
private void checkTerms(int maxTerms){
if (mustBeLessThanMaxTerms(maxTerms)) {
getPaymentAmount();
} else {
System.out.println("Maximum allowed term is " + maxTerms + " years");
getTermsAmount();
private void checkTerms(Integer maxTerms){
while(true) {
if (mustBeLessThanMaxTerms(maxTerms)) {
getPaymentAmount();
} else {
System.out.println("Maximum allowed term is " + maxTerms + " years");
getTermsAmount();
}
break;
}
}

private Boolean mustBeLessThanMaxTerms(int maxTerms){
private Boolean mustBeLessThanMaxTerms(Integer maxTerms){
return terms <= maxTerms;
}

public void getLoanInfo(int maxTerms){
getPrincipleAmount();
public void getLoanInfo(Integer maxTerms){
principle = getPrincipleAmount();
getTermsAmount();
checkTerms(maxTerms);
getInterest();
Expand All @@ -38,31 +41,31 @@ public void getLoanInfo(int maxTerms){
amortization.printEvaluation();
}

private void getPrincipleAmount(){
private Integer getPrincipleAmount(){
System.out.print("""
Enter your loan information.
Loan amount:\s""");
principle = scanner.nextInt();
return Integer.parseInt(scanner.nextLine());
}

private void getTermsAmount(){
System.out.print("Terms(year): ");
terms = scanner.nextInt();
terms = Integer.parseInt(scanner.nextLine());
}

private void getPaymentAmount(){
System.out.print("Number of payments in a single year: ");
paymentAmount = scanner.nextInt();
paymentAmount = Integer.parseInt(scanner.nextLine());
}

private void getInterest(){
System.out.print("Interest rate: ");
interest = scanner.nextDouble();
interest = Double.parseDouble(scanner.nextLine());
}

private void getGrossIncome(){
System.out.print("Gross income: ");
grossIncome = scanner.nextInt();
scanner.nextLine();
grossIncome = Integer.parseInt(scanner.nextLine());
// scanner.nextLine();
}
}

0 comments on commit 2de6be0

Please sign in to comment.