コード例 #1
0
 public int CreditScore(PersonalLoanEntity p)
 {
     if (p.CreditScore >= 650)
     {
         return(1);
     }
     else if (p.CreditScore > 600 || p.CreditScore < 650)
     {
         return(2);
     }
     else
     {
         return(0);
     }
 }
コード例 #2
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(PersonalLoanEntity p)
        {
            if ((p.LoanAmount != 0) && (p.LoanAmount >= 50000) && (p.Tenure != 0) && (p.Tenure >= 10))
            {
                // personalLoan.Emi = CalculateEmi();


                //float emi;
                float r = personalLoan.RateOfInterest / (12 * 100); // one month rate of interest it is a static value
                p.Tenure = p.Tenure * 12;                           // one month period
                p.Emi    = (p.LoanAmount * r * (float)Math.Pow(1 + r, p.Tenure)) / (float)(Math.Pow(1 + r, p.Tenure) - 1);

                return(p.Emi);
            }
            else
            {
                return(0);
                //throw new Exception("Please check and Enter the valid values");
            }
        }
 public void AddPersonalLoan(PersonalLoanEntity p)
 {
     _personalLoans.Add(p);
     ListOfPersonalLoanEntity();
 }
コード例 #4
0
 public void AddPersonalLoan(PersonalLoanEntity pl)
 {
     personalLoanData.AddPersonalLoan(pl);
 }
        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');
        }