package test;
import java.util.*;
class Vehicle
{
String brand;
int year;
void display()
{
System.out.println("Brand: "+brand+" Year: "+year);
}
}
class Car extends Vehicle
{
String model;
void displayCar()
{
System.out.println("Model: "+model);
}
}
class SportCar extends Car
{
String type;
int engine;
void displaySport()
{
System.out.println("Type: "+type+" Engine: "+engine);
}
}
public class Test {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
SportCar s1=new SportCar();
System.out.println("Enter the value of Car brand name and year:");
s1.brand=sc.nextLine();
s1.year=sc.nextInt();
sc.nextLine(); // consume leftover newline
System.out.println("Enter the value of Car model name :");
s1.model=sc.nextLine();
System.out.println("Enter the value of Car engine type and capacity:");
s1.type=sc.nextLine();
s1.engine=sc.nextInt();
s1.display();;
s1.displayCar();
s1.displaySport();
}
}