Saturday, 19 November 2022

Selection Control Structure - Assignment 5

Selection Control Structure - Assignment 5


The Metro Bank provides various types of loans such as car loans, business loans and house loans to its account holders, i.e., customers.

Implement a program to determine the eligible loan amount and the EMI that the bank can provide to its customers based on their salary and the loan type they expect to avail.

The values required for determining the eligible loan amount and the EMI are:

  • account number of the customer

  • account balance of the customer

  • salary of the customer

  • loan type 

  • expected loan amount

  • expected no. of EMIs

The following validations should be performed:

  • The account number should be of 4 digits and its first digit should be 1

  • The customer should have a minimum balance of $1000 in the account

Display appropriate error messages if the validations fail.

If the validations pass, determine whether the bank would provide the loan or not. 

The bank would provide the loan, only if the loan amount and the number of EMIs expected by the customer is less than or equal to the loan amount and the number of EMIs decided by the bank respectively. The bank decides the eligible loan amount and the number of EMIs based on the below table.

Display the account number, eligible and requested loan amount and the number of EMIs if the bank provides the loan.

Display an appropriate message if the bank does not provide the loan.

 

Sample Input and Output


class Tester{
public static void main(String[]args){
int accnmbr=1001;
int accbal=250000;
int salary=40000;
String loantype="Car";
int loanAmExpected=300000;
int emis=30;
int count=0;
int eligibleloanAmount=500000;
int eligibleEmis=36;
int a=accnmbr;
while(a!=0)
{
a=a/10;
count++;
}
if(count==4)
{
int firstdigit=accnmbr/1000;
if(firstdigit==1)
{
System.out.println("Youcanproceedfurther");
}
}
else{
System.out.println("LOANWILLNOTBEPROVIDED!!!");
}
if(accbal>=1000)
{
System.out.println("Youareeligibleforloan!");
}
else{
System.out.println("LOANWILLNOTBEPROVIDED!!!");
}
System.out.println("Checkingwhetherthebankapprovesforloan");if(loanAmExpected<=eligibleloanAmount)
{
if(emis<=eligibleEmis)
{
System.out.println("LOANAPPROVED!!!");
System.out.println("Accountnumber:"+accnmbr);
System.out.println("Loantype:"+loantype);
System.out.println("Eligibleloanamount:"+eligibleloanAmount);System.out.println("Loanamountrequested:"+loanAmExpected);System.out.println("NumberofeligibleEMIs:"+eligibleEmis);
System.out.println("NumberofrequestedEMIs:"+emis);
}
}
else{
System.out.println("BANKCANNOTPROVIDELOANTOYOURACCOUNT!!!");}
}
}


No comments:

Post a Comment

Free Resume Template

Creating a blog post that discusses the pros and cons of using a resume rule is a great way to provide valuable information to job seekers ...