public int CreditScore(VehicleLoanEntity v) { if (v.CreditScore >= 650) { return(1); } else if (v.CreditScore > 600 || v.CreditScore < 650) { return(2); } else { return(0); } }
//calculation of emi //If account number,loan amount,tenure and credit score value not equals to null and 0 then emi is calculated public float CalculateEmi(VehicleLoanEntity v) { if ((v.LoanAmount != 0) && (v.LoanAmount >= 50000) && (v.Tenure != 0) && (v.Tenure >= 10)) { // vehicleLoan.Emi = CalculateEmi(); //float emi; float r = vehicleLoan.RateOfInterest / (12 * 100); // one month rate of interest it is a static value v.Tenure = v.Tenure * 12; // one month period v.Emi = (v.LoanAmount * r * (float)Math.Pow(1 + r, v.Tenure)) / (float)(Math.Pow(1 + r, v.Tenure) - 1); return(v.Emi); } else { return(0); // throw new Exception("Please check and Enter the valid values"); } }
public static void Start() { Customer cus = new Customer(); PersonalLoanEntity pl = new PersonalLoanEntity(); //creating a object for personalloan entity VehicleLoanEntity vl = new VehicleLoanEntity(); //creating a object for vehicleloan entity PersonalLoanBusinessLogicLayer pb = new PersonalLoanBusinessLogicLayer(); //creating a object for personaloanbusinesslogiclayer VehicleLoanBusinessLogicLayer vb = new VehicleLoanBusinessLogicLayer(); //creating a object for vehicleloanbusinesslogiclayer char c = 'Y'; do { System.Console.WriteLine("*********WELCOME TO PECUNIA BANK***********\n"); System.Console.WriteLine("For LOAN ACCEPTANCE\n"); System.Console.WriteLine("1 - PERSONAL LOAN\n"); System.Console.WriteLine("2 - VEHICLE LOAN\n"); System.Console.WriteLine("3 - EXIT\n"); //switch case for checking whether to take personal loan or vehicle loan int n; n = int.Parse(System.Console.ReadLine()); switch (n) { //case 1 for personal loan case 1: System.Console.Write("\nEnter CustomerId : "); //Enter the customerId for personal loan pl.CustomerId = (int.Parse(System.Console.ReadLine())); /* pl.CustomerId = cus.CustomerId; * Customer s = pb.GetCustomersByCustomerId(pl.CustomerId); * WriteLine("Name" + s.CustomerName); * WriteLine("Profession" + s.Profession); * WriteLine("Address" + s.Address); * WriteLine("AnnualIncome" + s.AnnualIncome ); * WriteLine("PanCardNumber" + s.PanCardNumber ); * WriteLine("AadharCardNumber" + s.AadharCardNumber );*/ System.Console.Write("\nEnter the CreditScore : "); //Enter the credit score for loan acceptance of personal loan pl.CreditScore = (int.Parse(System.Console.ReadLine())); if (pb.CreditScore(pl) == 1) //If credit score value greater than or equal to 650 loan is accepted { try { System.Console.Write("\nEnter the LoanAmount : "); //Enter the Loan amount for the personalloan pl.LoanAmount = (float.Parse(System.Console.ReadLine())); if (pl.LoanAmount >= 50000) //If loan amount is greater than 50000 it is accepted { pb.AddPersonalLoan(pl); } else { throw new PersonalLoanException("Amount Should be Greater than 50000"); //If loan amount is less than 50000 it is calculated } } catch (PersonalLoanException ex) { Console.WriteLine(ex.Message); //throw; break; } try { System.Console.Write("\nEnter the Tenure in months : "); //Enter the tenure in months for the personalloan pl.Tenure = (float.Parse(System.Console.ReadLine())); if (pl.Tenure >= 10) { pb.AddPersonalLoan(pl); } else { throw new PersonalLoanException("Tenure should be greater than 10 months"); //Tenure should be greater than 10 months } } catch (PersonalLoanException ex) { Console.WriteLine(ex.Message); break; } pb.AddPersonalLoan(pl); //enter the loanamount,tenure for calculation of emi System.Console.WriteLine("\n Congratulations...............your loan is accepted"); if (pb.CalculateEmi(pl) == 0) { System.Console.WriteLine("sorry Your loan is rejected "); } else { Console.Write("\nThe Monthly EMI you have to pay is : " + pl.Emi); //EMI is calcuated pb.AddPersonalLoan(pl); } } else if (pb.CreditScore(pl) == 2) { Console.WriteLine(" \nYour Loan is in Pending status,please apply loan when your credit score is above 650\n"); } else //if credit score value less than 650 loan is rejected { System.Console.WriteLine("sorry Your loan is rejected "); } break; //case 2 for vehicleloan case 2: System.Console.Write("Enter the name of vehicle:"); //Enter the name of vehicle you want to buy vl.NameOfVehicle = System.Console.ReadLine(); System.Console.Write("\nEnter CustomerId : "); //Enter the customerid for vehicle loan vl.CustomerId = (int.Parse(System.Console.ReadLine())); System.Console.Write("\nEnter the CreditScore : "); //Enter the credit score for your loan acceptance of vehicle loan int q = (int.Parse(System.Console.ReadLine())); vl.CreditScore = q; if (vb.CreditScore(vl) == 1) //If credit score value greater than or equal to 650 loan is accepted { try { System.Console.Write("\nEnter the LoanAmount : "); //Enter the Loan amount for the personalloan vl.LoanAmount = (float.Parse(System.Console.ReadLine())); if (pl.LoanAmount >= 50000) { pb.AddPersonalLoan(pl); } else { throw new PersonalLoanException("Amount Should be Greater than 50000"); } } catch (PersonalLoanException ex) { Console.WriteLine(ex.Message); break; } try { System.Console.Write("\nEnter the Tenure in months : "); //Enter the tenure in months for the personalloan vl.Tenure = (float.Parse(System.Console.ReadLine())); if (pl.Tenure >= 10) { pb.AddPersonalLoan(pl); } else { throw new PersonalLoanException("Tenure should be greater than 10 months"); //Tenure should be not less than 10months } } catch (PersonalLoanException ex) { Console.WriteLine(ex.Message); break; } vb.AddVehicleLoan(vl); //enter the loanamount,tenure for calculation of emi System.Console.WriteLine("\n Congratulations...............your loan is accepted"); //If loan is accepted congratulations message is displayed on the screen if (vb.CalculateEmi(vl) == 0) { System.Console.WriteLine("sorry Your loan is rejected "); } else { Console.Write("\nThe Monthly EMI you have to pay is : " + vl.Emi); //Emi is calcualted vb.AddVehicleLoan(vl); } } else if (vb.CreditScore(vl) == 2) { Console.WriteLine(" \nYour Loan is in Pending status,please apply loan when your credit score is above 650\n"); } else //if credit score value less than 650 loan is rejected { System.Console.WriteLine("sorry Your loan is rejected "); } break; case 3: Console.WriteLine("Thanks For Using PECUNIA BANK"); //Thankfull message once the process is completed break; default: System.Console.WriteLine("\nplease choose the correct Option\n"); break; } Console.Write("\nIf You Want to Use Again Press Y/N : "); c = char.Parse(Console.ReadLine()); } while (c == 'Y' || c == 'y'); }
public void AddVehicleLoan(VehicleLoanEntity vl) { vehicleLoanData.AddVehicleLoan(vl); }
public void AddVehicleLoan(VehicleLoanEntity v) { _vehicleLoans.Add(v); ListOfVehicleLoanEntity(); }