import java.util.
*;
class Publication
{
String title=null;
float price=0;
int copy=0;
void get()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the title : ");
title=sc.nextLine();
System.out.println("Enter price of 1: ");
price=sc.nextFloat();
System.out.println("Enter number of copies: ");
copy=sc.nextInt();
}
void display()
{
System.out.println("The title is: "+title);
System.out.println("The price is: "+price);
System.out.println("Number of copies are: "+copy);
}
void sale()
{
float tot;
int x;
int z;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number of copies sold: ");
x=sc.nextInt();
tot=price*x;
z=copy-x;
System.out.println("The sale is: "+tot);
System.out.println("Available copies are: "+z);
}
}
class Book extends Publication
{
String author;
void books()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the author's name: ");
author=sc.nextLine();
System.out.println("Author of the book is: "+author);
}
}
class Magazine extends Publication
{
int ordqty;
String currentissue;
void magazines()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number of copies sold: ");
ordqty=sc.nextInt();
}
void issue()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the date to be displayed in manner:
day/month/year");
currentissue=sc.nextLine();
System.out.println("The issue date of magazine is: ");
System.out.println(currentissue);
}
}
public class Main
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Welcome to the Publication");
while(true)
{
System.out.println("Press according to your choice 1. Books 2. Magazines 3.
EXIT");
int ch;
ch=sc.nextInt();
switch(ch)
{
case 1:
System.out.println("Book Operation");
Book b1 = new Book();
b1.get();
b1.books();
b1.display();
b1.sale();
break;
case 2:
System.out.println("Magazine Operation");
Magazine m1 = new Magazine();
m1.get();
m1.magazines();
m1.display();
m1.sale();
m1.issue();
break;
case 3:
System.out.println("Thank you");
System.exit(0);
break;
default:
System.out.println("Enter proper choice: ");
}
}
}
}