-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day-13.txt
39 lines (31 loc) · 877 Bytes
/
Day-13.txt
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
import java.util.*;
abstract class Book {
String title;
String author;
Book(String title, String author) {
this.title = title;
this.author = author;
}
abstract void display();
}
class MyBook extends Book{
int price;
MyBook(String title, String author, int price){
super(title,author);
this.price = price;
}
void display(){
System.out.print("Title: "+title+"\n"+"Author: "+author+"\n"+"Price: "+price);
}
}
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String title = scanner.nextLine();
String author = scanner.nextLine();
int price = scanner.nextInt();
scanner.close();
Book book = new MyBook(title, author, price);
book.display();
}
}