-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasics12.java
More file actions
40 lines (31 loc) · 828 Bytes
/
Basics12.java
File metadata and controls
40 lines (31 loc) · 828 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
32
33
34
35
36
37
package irene;
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 double calculateTotal() {
return (price*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" +calculateTotal());
}
}
public class Basics12 {
public static void main(String[] args) {
Book Book1=new Book("Alchemist","Paulo Coelho",100,50);
Book Book2=new Book("Beloved","Toni Morrison",250,50);
Book1.displayDetails();
Book2.displayDetails();
}
}