import java.util.*;
class CarPrice
{
public static void main (String args[])
{
Ford fr = new Ford();
fr.getcarmaker();
fr.setPrice();
Chevy ch = new Chevy();
ch.getcarmaker();
ch.setPrice();
fr.displyinfo();
ch.displyinfo();
}
}
abstract class Auto
{
abstract void getcarmaker();
abstract void setPrice();
}
class Ford extends Auto
{
Scanner in = new Scanner (System.in);
double price;
String maker;
void getcarmaker()
{
System.out.print ("\n\t Enter the name of car maker = ");
maker=in.nextLine();
}
void setPrice()
{
System.out.print ("\n\t Enter price of "+maker+" car = $");
price=in.nextDouble();
}
void displayinfo()
{
System.out.println ("\n\t Car maker = "+maker);
System.out.println ("\n\t Car Price = $"+price);
}
}
class Chevy extends Auto
{
Scanner in = new Scanner (System.in);
double price;
String maker;
void getcarmaker()
{
System.out.print ("\n\t Enter the name of car maker = ");
maker=in.nextLine();
}
void setPrice()
{
System.out.print ("\n\t Enter price of "+maker+" car = $");
price=in.nextDouble();
}
void displayinfo()
{
System.out.println ("\n\t Car maker = "+maker);
System.out.println ("\n\t Car Price = $"+price);
}
}
class CarPrice
{
public static void main (String args[])
{
Ford fr = new Ford();
fr.getcarmaker();
fr.setPrice();
Chevy ch = new Chevy();
ch.getcarmaker();
ch.setPrice();
fr.displyinfo();
ch.displyinfo();
}
}
abstract class Auto
{
abstract void getcarmaker();
abstract void setPrice();
}
class Ford extends Auto
{
Scanner in = new Scanner (System.in);
double price;
String maker;
void getcarmaker()
{
System.out.print ("\n\t Enter the name of car maker = ");
maker=in.nextLine();
}
void setPrice()
{
System.out.print ("\n\t Enter price of "+maker+" car = $");
price=in.nextDouble();
}
void displayinfo()
{
System.out.println ("\n\t Car maker = "+maker);
System.out.println ("\n\t Car Price = $"+price);
}
}
class Chevy extends Auto
{
Scanner in = new Scanner (System.in);
double price;
String maker;
void getcarmaker()
{
System.out.print ("\n\t Enter the name of car maker = ");
maker=in.nextLine();
}
void setPrice()
{
System.out.print ("\n\t Enter price of "+maker+" car = $");
price=in.nextDouble();
}
void displayinfo()
{
System.out.println ("\n\t Car maker = "+maker);
System.out.println ("\n\t Car Price = $"+price);
}
}
No comments:
Post a Comment