-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
28 lines (25 loc) · 1003 Bytes
/
Copy pathTransaction.java
File metadata and controls
28 lines (25 loc) · 1003 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
public class Transaction {
private String type;
private String stockSymbol;
private int quantity;
private double price;
private double totalAmount;
// Constructor
public Transaction(String type, String stockSymbol, int quantity, double price) {
this.type = type;
this.stockSymbol = stockSymbol;
this.quantity = quantity;
this.price = price;
this.totalAmount = quantity * price;
}
// Display transaction details
public void displayTransaction() {
System.out.println("----------------------------------------");
System.out.println("Transaction Type : " + type);
System.out.println("Stock Symbol : " + stockSymbol);
System.out.println("Quantity : " + quantity);
System.out.printf("Price : ₹%.2f%n", price);
System.out.printf("Total Amount : ₹%.2f%n", totalAmount);
System.out.println("----------------------------------------");
}
}