- Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbookDetails.java
More file actions
Latest commit
91 lines (84 loc) · 2.5 KB
/
Copy pathbookDetails.java
File metadata and controls
91 lines (84 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
importjava.util.Scanner;
classPublisher{
Stringpublisher;
Publisher(Stringpub){
this.publisher=pub;
}
}
classBookextendsPublisher{
Stringbook;
Book(Stringpub,Stringboo){
super(pub);
book=boo;
}
}
classLiteratureextendsBook{
Stringcategory;
Literature(Stringpub, Stringboo){
super(pub, boo);
}
voiddisplay(){
System.out.println("Publisher :"+publisher);
System.out.println("Book :"+book);
}
}
classFictionextendsBook{
Fiction(Stringpub, Stringboo){
super(pub, boo);
}
voiddisplay(){
System.out.println("Publisher :"+publisher);
System.out.println("Book :"+book);
}
}
publicclassbookDetails{
publicstaticvoidmain(String[] args) {
System.out.print("\nEnter the No. of Literature Books : ");
Scannersc1 = newScanner(System.in);
intnum = sc1.nextInt();
Literaturearr[]=newLiterature[num];
System.out.println("\n Enter the Literature Book Details\n");
intx = 0,j=0;
Scannersc =newScanner(System.in);
for(inti =0;i<num;i++)
{
x = i +1;
System.out.println("\n"+x+").");
System.out.print("\n Book : ");
Stringboo =sc.next();
System.out.print("\n Publisher: ");
Stringpub =sc.next();
arr[i]=newLiterature(boo,pub);
}
System.out.print("\nEnter the No. of Fiction Books : ");
intnum1 = sc1.nextInt();
Fictionarr1[]=newFiction[num1];
System.out.print("\n Enter the Fiction Book Details : \n");
intx1 = 0,j1=0;
for(inti =0;i<num1;i++)
{
x1 = i +1;
System.out.println("\n"+x1+").");
System.out.print("\n Book : ");
Stringboo =sc.next();
System.out.print("\n Publisher: ");
Stringpub =sc.next();
arr1[i]=newFiction(boo,pub);
}
sc.close();
sc1.close();
System.out.println("\n---Informations of all the Literature Books---");
for(inti=0;i<num;i++){
j=i+1;
System.out.println("\n"+j+").");
arr[i].display();
}
System.out.println("\n---Informations of all the Fiction Books---");
for(inti=0;i<num1;i++){
j1=i+1;
System.out.println("\n"+j1+").");
arr1[i].display();
}
sc1.close();
}
}