You are on page 1of 23

//bank details

import java.util.*;

class Account

String holderName;

Long accountNumber;

String IFSCCode;

Long contactNumber;

public String getholderName(){

return holderName;

public void setholderName(String h){

this.holderName=h;

public Long getaccountNumber(){

return accountNumber;

public void setaccountNumber(Long s){

this.accountNumber=s;

public String getIFSCCode(){

return IFSCCode;
}

public void setIFSCCode(String i){

this.IFSCCode=i;

public Long getcontactNumber(){

return contactNumber;

public void setcontactNumber(Long c){

this.contactNumber=c;

public void method1(String holderName,Long accountNumber,String IFSCCode,Long contactNumber)

this.holderName = holderName;

this.accountNumber = accountNumber;

this.IFSCCode = IFSCCode;

this.contactNumber = contactNumber;

public void display()

System.out.println(holderName+","+accountNumber+","+IFSCCode+","+contactNumber);

class SavingsAccount extends Account


{

double interestRate;

public double getinterestRate(){

return interestRate;

public void setinterestRate(double d){

this.interestRate=d;

public void method2(String holderName,Long accountNumber,String IFSCCode,Long


contactNumber,Double interestRate)

this.holderName = holderName;

this.accountNumber = accountNumber;

this.IFSCCode = IFSCCode;

this.contactNumber = contactNumber;

this.interestRate = interestRate;

public void display()

System.out.println("Your contact details");

System.out.println("Holder Name:"+holderName);

System.out.println("Account number:"+accountNumber);

System.out.println("IFSC code:"+IFSCCode);

System.out.println("Contact Number:"+contactNumber);

System.out.println("Interest Rate:"+interestRate);
}

class CurrentAccount extends Account{

String organizationName;

Long TIN;

public void method3(String holderName,Long accountNumber,String IFSCCode,Long


contactNumber,String organizationName,Long TIN)

this.holderName = holderName;

this.accountNumber = accountNumber;

this.IFSCCode = IFSCCode;

this.contactNumber = contactNumber;

this.organizationName = organizationName;

this.TIN = TIN;

public void display()

System.out.println("Your contact details");

System.out.println("Holder Name:"+holderName);

System.out.println("Account number:"+accountNumber);

System.out.println("IFSC code:"+IFSCCode);

System.out.println("Contact Number:"+contactNumber);

System.out.println("Name of the organization:"+organizationName);

System.out.println("TIN:"+TIN);

}
}

class Main

public static void main(String args[])

Account ac = new Account();

System.out.println("Enter user details(HolderName,Account Number,IFSC code,Contact Number)");

Scanner sc = new Scanner(System.in);

String Name = sc.next();

Long accNo = sc.nextLong();

String ifsc = sc.next();

Long conNo = sc.nextLong();

ac.method1(Name,accNo,ifsc,conNo);

ac.display();

System.out.println("Enter Account type:");

String type = sc.next();

switch(type){

case "savings":

SavingsAccount sa = new SavingsAccount();

System.out.println("Enter Interest Rate:");

double ir = sc.nextDouble();

sa.method2(Name,accNo,ifsc,conNo,ir);

sa.display();

break;

case "current":
CurrentAccount ca = new CurrentAccount();

System.out.println("Enter organization name:");

String org = sc.next();

System.out.println("Enter TIN Number:");

Long tin = sc.nextLong();

ca.method3(Name,accNo,ifsc,conNo,org,tin);

ca.display();

break;

default:

System.out.println("Enter valid account type!!!");

}
//shapes

import java.util.*;

abstract class Shape

double a,b;

abstract void calculatePerimeter();

class Circle extends Shape

void calculatePerimeter()

System.out.println("---Calculating area of circle---");

Scanner in = new Scanner(System.in);

System.out.println("Enter radius:");

a=in.nextDouble();

double area = 3.14*a*a;

System.out.println("Area of circle:" +area);

class Rectangle extends Shape

void calculatePerimeter()

System.out.println("---Calculating area of rectangle---");

Scanner in = new Scanner(System.in);


System.out.println("Enter length:");

a=in.nextDouble();

System.out.println("\nEnter bredth:");

b=in.nextDouble();

double area = a*b;

System.out.println("Area of rectangle:" +area);

class Square extends Shape

void calculatePerimeter()

System.out.println("---Calculating area of square---");

Scanner in = new Scanner(System.in);

System.out.println("Enter side:");

a=in.nextDouble();

double area = a*a;

System.out.println("Area of square:" +area);

class Main

public static void main (String args[])

{
System.out.println("List of shapes: ");

System.out.println("1.Circle");

System.out.println("2.Rectangle");

System.out.println("3.Square");

System.out.println("Enter your choice:");

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

Shape obj;

switch(n)

case 1:

obj = new Circle();

obj.calculatePerimeter();

break;

case 2:

obj = new Rectangle();

obj.calculatePerimeter();

break;

case 3:

obj = new Square();

obj.calculatePerimeter();

break;

}
//aircraft

import java.util.*;

class Aircraft

String aircraftName;

String source;

String destination;

void method1(String aircraftName,String source,String destination)


{

this.aircraftName=aircraftName;

this.source=source;

this.destination=destination;

void displayDetails()

System.out.println("Enter the aircraft Name: "+aircraftName);

System.out.println("Enter source: "+source);

System.out.println("Enter destination: "+destination);

class PublicAircraft extends Aircraft


{

String checkinbeforetwohours;

int noOfKgsallowed;

float additionalFeesperkg;

public String getcheckinbeforetwohours(){

return checkinbeforetwohours;

public void setcheckinbeforetwohours(String b){

this.checkinbeforetwohours=b;

}
public int getnoOfKgsallowed(){

return noOfKgsallowed;

public void setnoOfKgsallowed(int i){

this.noOfKgsallowed = i;

public float getadditionalFeesperkg(){

return additionalFeesperkg;

public void setadditionalFeesperkg(float f){

this.additionalFeesperkg = f;

}
void method2(String aircraftName,String source,String destination,String checkinbeforetwohours,int
noOfKgsallowed,float additionalFeesperkg){

this.aircraftName = aircraftName;

this.source = source;

this.destination = destination;

this.checkinbeforetwohours = checkinbeforetwohours;

this.noOfKgsallowed = noOfKgsallowed;

this.additionalFeesperkg = additionalFeesperkg;

void displayDetails()

System.out.println("Aircraft Name: "+aircraftName);

System.out.println("Source: "+source);

System.out.println("Destination: "+destination);

System.out.println("Check in before two hours: "+checkinbeforetwohours);

System.out.println("No Of Kgs allowed: "+noOfKgsallowed);

System.out.println("Additional Fees per kg: "+additionalFeesperkg);

}
class PrivateAircraft extends Aircraft

String checkinbeforetwohours;

String pilotPreference;

String purpose;

public String getcheckinbeforetwohours(){

return checkinbeforetwohours;

public void setcheckinbeforetwohours(String b){

this.checkinbeforetwohours = b;

}
public String getpilotPreference(){

return pilotPreference;

public void setpilotPreference(String s){

this.pilotPreference = s;

public String getpurpose(){

return purpose;

public void setpurpose(String ss){

this.purpose = ss;
}

void method3(String aircraftName,String source,String destination,String


checkinbeforetwohours,String pilotPreference ,String purpose){

this.aircraftName = aircraftName;

this.source = source;

this.destination = destination;

this.checkinbeforetwohours = checkinbeforetwohours;

this.pilotPreference = pilotPreference;

this.purpose = purpose;

void displayDetails()

System.out.println("Aircraft Name: "+aircraftName);

System.out.println("Source: "+source);

System.out.println("Destination: "+destination);

System.out.println("Check in before two hours: "+checkinbeforetwohours);

System.out.println("Pilot Name: "+pilotPreference);

System.out.println("Purpose: "+purpose);

}
public class Main extends Aircraft

public static void main(String args[])

Aircraft ac = new Aircraft();

ac.method1("JET", "Kolkata", "Chennai");

ac.displayDetails();

System.out.println("Enter the type of aircraft:");

Scanner sc = new Scanner(System.in);

int n = sc.nextInt();

switch(n){

case 1:
PublicAircraft obj1 = new PublicAircraft();

int noOfKgsallowed = sc.nextInt();

int extraamnt = sc.nextInt();

obj1.method2("JET", "Kolkata", "Chennai","YES",noOfKgsallowed,extraamnt);

System.out.println("Public Aircraft");

obj1.displayDetails();

break;

case 2:

PrivateAircraft obj2 = new PrivateAircraft();

String nameOfPilot = sc.next();

String purpose = sc.next();

obj2.method3("Spice jet","Chennai","Bangalore","NO",nameOfPilot,purpose);

System.out.println("Private Aircraft");
obj2.displayDetails();

break;

You might also like