-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookStore.java
More file actions
31 lines (28 loc) · 791 Bytes
/
BookStore.java
File metadata and controls
31 lines (28 loc) · 791 Bytes
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
package jxh;
class Book {
String title;
String author;
double price;
int quantity;
Book(String title, String author, double price, int quantity){
this.title=title;
this.author=author;
this.price=price;
this.quantity=quantity;
}
public void displayDetails() {
System.out.println("Title: " + title);
System.out.println("Author: " + author);
System.out.println("Price: " + price);
System.out.println("Quantity: " + quantity);
System.out.println("Total Value: " + (price*quantity));
}
}
public class BookStore {
public static void main(String[] args) {
Book b1= new Book("Title 1","Author 1",150,500);
b1.displayDetails();
Book b2= new Book("Title 2","Author 2",200,400);
b2.displayDetails();
}
}