Showing posts with label infosys assignmenet and quiz. Show all posts
Showing posts with label infosys assignmenet and quiz. Show all posts

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!!!");}
}
}


Selection Control Structure - Assignment 2

 

Selection Control Structure - Assignment 2

Problem Statement

Quadratic equation is an equation with degree 2 in the form of             ax2+bx + c = 0 where a, b and c are the coefficients.

Implement a program to solve a quadratic equation.

Find the discriminant value using the formula given below.

discriminant = b2 - 4ac

  • If the discriminant is 0, the values of both the roots will be same. Display the value of the root.

  • If the discriminant is greater than 0, the roots will be unequal real roots. Display the values of both the roots.

  • If the discriminant is less than 0, there will be no real roots. Display the message "The equation has no real root"

Use the formula given below to find the roots of a quadratic equation.

x = (-b ± discriminant)/2a

Sample Input and Output

class Tester{
public static void main(String[]args){
int a=1,b=4,c=6;
float dis=0f;
float x1=0f;
float x2=0f;
dis=(float)((b*b)-4*a*c);
System.out.println(dis);
if(dis==0)
{
System.out.println(":");
}
else if(dis>0)
{
System.out.println(":");
}
else{
    System.out.println("The equation has no real roots ");
}
x1=(float)((-b+dis)/(2*a));
x2=(float)((-b-dis)/(2*a));
System.out.println(x1);
System.out.println(x2);
}
}


Methods - Assignment 4

 Methods - Assignment 4


Implement a class Rectangle with the instance variables and methods mentioned below. 

Method Description

calculateArea()

  • Calculate and return the area of the rectangle. The area should be rounded off to two decimal digits.

calculatePerimeter()

  • Calculate and return the perimeter of the rectangle. The perimeter should be rounded off to two decimal digits.

Test the functionalities using the provided Tester class. 

 

Sample Input and Output


class Rectangle{
public float length;
public float width;
public double calculateArea()
{
double a=length*width;
double area=Math.round(a*100.0)/100.0;
return area;
}
public double calculatePerimeter()
{
double p=2*(length+width);
double perimeter=Math.round(p*100.0)/100.0;
return perimeter;
}
}
class Tester{
public static void main(String args[]){
Rectangle rectangle=new Rectangle();
//AssignvaluestothemembervariablesofRectangleclass
rectangle.length=12f;
rectangle.width=5f;
//InvokethemethodsoftheRectangleclasstocalculatetheareaandperimeter
double x=rectangle.calculateArea();
double y=rectangle.calculatePerimeter();
//Displaytheareaandperimeterusingthelinesgivenbelow
System.out.println("Areaoftherectangleis"+x);
System.out.println("Perimeteroftherectangleis"+y);
}
}













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 ...