Created
October 16, 2017 22:39
-
-
Save viveknarang/e115c434a8d61318d1c7d47a4b36b8ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Sample { | |
public static void main(String[] args) { | |
String name; | |
String gender; | |
String criminalRecord; | |
String timelyCreditPayment; | |
int income; | |
int year; | |
boolean recommendLoan = false; | |
Scanner scanner = new Scanner(System.in); | |
System.out.println("Please enter your name."); | |
name = scanner.next(); | |
System.out.println("Please enter your gender."); | |
gender = scanner.next(); | |
System.out.println("Please enter your criminal record."); | |
criminalRecord = scanner.next(); | |
System.out.println("Please enter timely credit payment"); | |
timelyCreditPayment = scanner.next(); | |
System.out.println("Please enter income."); | |
income = scanner.nextInt(); | |
System.out.println("Please enter year."); | |
year = scanner.nextInt(); | |
if (!(gender.equals("Male") || gender.equals("Female"))) { | |
System.out.println("Gender value incorrect."); | |
} else if (!(criminalRecord.equals("Yes") || criminalRecord.equals("No"))) { | |
System.out.println("timely credit payment value incorrect."); | |
} else if (!(timelyCreditPayment.equals("Yes") || timelyCreditPayment.equals("No"))) { | |
System.out.println("timely credit payment value incorrect."); | |
} else if (income < 0) { | |
System.out.println("income value incorrect."); | |
} else if (year < 0) { | |
System.out.println("income value incorrect."); | |
} else { | |
if (income < 30000) { | |
if (criminalRecord.equals("Yes")) { | |
recommendLoan = true; | |
} else if (criminalRecord.equals("No")) { | |
recommendLoan = false; | |
} | |
} else if (income >= 30000 && income < 70000) { | |
if (year < 1) { | |
recommendLoan = false; | |
} else if (year >= 1 & year <= 5) { | |
if (timelyCreditPayment.equals("Yes")) { | |
recommendLoan = true; | |
} else if (timelyCreditPayment.equals("No")) { | |
recommendLoan = false; | |
} | |
} else if (year > 5) { | |
recommendLoan = true; | |
} | |
} else if (income >= 70000) { | |
if (criminalRecord.equals("No")) { | |
recommendLoan = true; | |
} else if (criminalRecord.equals("Yes")) { | |
recommendLoan = false; | |
} | |
} | |
if (recommendLoan == true) { | |
if (gender.equals("Male")) { | |
System.out.println("Dear Mr " + name + " , congratulations bla bla bla ..."); | |
} else { | |
System.out.println("Dear Mrs " + name + " , congratulations bla bla bla ..."); | |
} | |
} else { | |
if (gender.equals("Male")) { | |
System.out.println("Dear Mr " + name + " , screw you! bla bla bla ..."); | |
} else { | |
System.out.println("Dear Mrs " + name + " , screw you! bla bla bla ..."); | |
} | |
} | |
} | |
scanner.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment