-
Notifications
You must be signed in to change notification settings - Fork 0
/
InvoiceDemo.java
94 lines (63 loc) · 1.83 KB
/
InvoiceDemo.java
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
import java.util.Scanner;
class Invoice {
String partNumber;
String partDescription;
int quantity;
double pricePerItem;
double invoiceAmmount;
//seting partNumber
void setPartNumber(String pnum) {
partNumber = pnum;
}
// seting getpartNumber
String getPartNumber() {
return partNumber;
}
// seting partDescription
void setPartDescription(String pdescription) {
partDescription = pdescription;
}
// geting partDescription
String getPartDescription() {
return partDescription;
}
void setQuantity (int quan) {
quantity = quan;
}
int getQuantity() {
return quantity;
}
void setPricePerItem(double priceperitem) {
pricePerItem = priceperitem;
}
double getPricePerItem() {
return pricePerItem;
}
double getInvoiceAmmount() {
return quantity * pricePerItem;
}
}
public class InvoiceDemo {
public static void main(String args[]) {
Invoice obj1 = new Invoice();
Scanner scanner = new Scanner(System.in);
System.out.print("Enter Part Number: ");
String partNumber = scanner.nextLine();
obj1.setPartNumber(partNumber);
System.out.print("Enter Part Description: ");
String partDescription = scanner.nextLine();
obj1.setPartDescription(partDescription);
System.out.print("Enter price per item: ");
double pricePerItem = scanner.nextDouble();
obj1.setPricePerItem(pricePerItem);
System.out.print("Enter Quantity: ");
int quantity = scanner.nextInt();
obj1.setQuantity(quantity);
scanner.close();
System.out.println("Part Number: " + obj1.getPartNumber());
System.out.println("Part Description: " + obj1.getPartDescription());
System.out.println("quantity: " + obj1.getQuantity());
System.out.println("price per item: " + obj1.getPricePerItem());
System.out.println("Invoice ammount: " + obj1.getInvoiceAmmount());
}
}