- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPurchase.java
More file actions
Latest commit
93 lines (80 loc) · 2.41 KB
/
Copy pathPurchase.java
File metadata and controls
93 lines (80 loc) · 2.41 KB
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
92
93
importjava.util.Scanner;
publicclassCustomer_Purchases {
privatelongcustomer_number;
privateStringfirst_name,surname,product;
privateintprice,quantity;
publiclonggetCustomer_number() {
returncustomer_number;
}
publicvoidsetCustomer_number(longcustomer_number) {
this.customer_number = customer_number;
}
publicStringgetFirst_name() {
returnfirst_name;
}
publicvoidsetFirst_name(Stringfirst_name) {
this.first_name = first_name;
}
publicStringgetSurname() {
returnsurname;
}
publicvoidsetSurname(Stringsurname) {
this.surname = surname;
}
publicStringgetProduct() {
returnproduct;
}
publicvoidsetProduct(Stringproduct) {
this.product = product;
}
publicintgetPrice() {
returnprice;
}
publicvoidsetPrice(intprice) {
this.price = price;
}
publicintgetQuantity() {
returnquantity;
}
publicvoidsetQuantity(intquantity) {
this.quantity = quantity;
}
}
classPrinting
{
Customer_Purchasesobj=newCustomer_Purchases();
voidprintDetails()
{
System.out.println(obj.getFirst_name()+" "+obj.getSurname());
System.out.println(obj.getCustomer_number());
System.out.println(obj.getProduct()+" Rs."+obj.getPrice()+" "+obj.getQuantity()+" piece");
customerPurchaseReport();
}
voidcustomerPurchaseReport()
{
floattotal=obj.getQuantity()*obj.getPrice();
floattax=(15*total/100);
floatcommission=8.5f*total/100;
floatdiscount=10*total/100;
total=total+tax-(discount+commission);
System.out.println(" Tax =15% = Rs."+tax);
System.out.println("Commission =8.5%=Rs."+commission);
System.out.println("Discount=10%=Rs."+discount);
System.out.println("Total =Rs."+total);
}
}
classPurchase
{
publicstaticvoidmain(String[] args) {
Scannersc=newScanner(System.in);
Printingob=newPrinting();
System.out.println("Enter first name, surname ,number,product,price,quantity");
ob.obj.setFirst_name(sc.next());
ob.obj.setSurname(sc.next());
ob.obj.setCustomer_number(sc.nextLong());
ob.obj.setProduct(sc.next());
ob.obj.setPrice(sc.nextInt());
ob.obj.setQuantity(sc.nextInt());
ob.printDetails();
}
}