Import Java.util.;1
Import Java.util.;1
*;
public class polymorphism {
String title,author;
int price,copies;
static int total=0;
void showtotalsales() {
System.out.println("total sale of the publiccation is:"+total);
}
}
class book extends polymorphism{
private int copies;
public void getData()
{
Scanner sc=new Scanner(System.in);
System.out.println("enter book details:");
System.out.println("enter the title of thee book:");
title=sc.nextLine();
System.out.println("enter the author name:");
author=sc.nextLine();
System.out.println("enter the price of the book:");
price=sc.nextInt();
System.out.println("enter the number of copies:");
copies=sc.nextInt();
}
void ordercopies() {
System.out.println("number of copies order:"+copies);
}
void showtotalsales() {
int sale=price*copies;
System.out.println("sale is:"+sale);
total+=sale;
}
}
class magzine extends polymorphism{
private int orderquantities;
private int currentIssues;
public void getData() {
Scanner sc=new Scanner(System.in);
System.out.println("enter magzine details:");
System.out.println("enter title of magzine:");
title=sc.nextLine();
System.out.println("enter order quantities:");
orderquantities=sc.nextInt();
System.out.println("enter current issues:");
currentIssues=sc.nextInt();
System.out.println("enter the price of magzine:");
price=sc.nextInt();
}
void receiveIssue() {
System.out.println("current issues:"+currentIssues);
}
void showtotalsales() {
int sale=price*orderquantities;
System.out.println("sale is:"+sale);
total+=sale;
}
}
public class BookSub{
public static void main (String[]args) {
int ch;
Scanner sc=new Scanner(System.in);
do {
System.out.println("enter the choice:");
System.out.println("1:book");
System.out.println("2:magzine");
System.out.println("3:show total sales");
System.out.println("4:exit");
ch=sc.nextInt();
switch(ch) {
case 1:
Book1 b=new book1();
b.getdata();
b.ordercopies();
b.showtotalsales();
break;
case 2:
magzine m=new magzine();
m.getData();
m.receiveIssue();
m.showtotalsales();
break;
case 4:
System.out.println("Exit");
break;
default:
System.out.println("wrong choice");
break;
}
}while(ch!=4);
}}