-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSuperMarket.java
More file actions
133 lines (113 loc) · 3.89 KB
/
SuperMarket.java
File metadata and controls
133 lines (113 loc) · 3.89 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import java.util.Scanner;
public class SuperMarket {
public static void main(String[] args) {
String itemno, name, cid, cname, address, phno;
double price;
int qty;
System.out.println("Enter Product Details : 1.Id, 2.Name, 3.Price, 4.Qty");
Scanner sc = new Scanner(System.in);
itemno = sc.next();
name = sc.next();
price = sc.nextDouble();
qty = sc.nextInt();
System.out.println("Enter Customer Details : 1.Id, 2.Name, 3.Address, 4.Phone Number");
cid = sc.next();
cname = sc.next();
address = sc.nextLine();
phno = sc.next();
Product p = new Product(itemno, name, price, qty);
System.out.println("Item No. = " + p.getItem_no());
System.out.println("Product Name = " + p.getName());
System.out.println("Product Price = " + p.getPrice());
System.out.println("Quantity = " + p.getQty());
Customer c = new Customer(cid, cname, address, phno);
System.out.println("Customer Id = " + c.c_id);
System.out.println("Customer Name = " + c.c_name);
System.out.println("Customer Address = " + c.address);
System.out.println("Customer Phone Number = " + c.ph_no);
System.out.println("Change your Product Price and Quantity : ");
price = sc.nextDouble();
qty = sc.nextInt();
p.setPrice(price);
p.setQty(qty);
System.out.println("Changed Details are : ");
System.out.println("Item No. = " + p.getItem_no());
System.out.println("Product Name = " + p.getName());
System.out.println("Product Price = " + p.getPrice());
System.out.println("Quantity = " + p.getQty());
System.out.println("Change your Customer Address and Phone Number : ");
address = sc.nextLine();
phno = sc.next();
c.setAddress(address);
c.setPh_no(phno);
System.out.println("Changed Details are : ");
System.out.println("Customer Id = " + c.getC_id());
System.out.println("Customer Name = " + c.getC_name());
System.out.println("Customer Address = " + c.getAddress());
System.out.println("Customer Phone Number = " + c.getPh_no());
}
static class Customer {
String c_id, c_name, address, ph_no;
// public Customer(String c_id, String c_name) {
// this.c_id = c_id;
// this.c_name = c_name;
// }
public Customer(String c_id, String c_name, String address, String ph_no) {
this.c_name = c_name;
this.c_id = c_id;
this.address = address;
this.ph_no = ph_no;
}
String getC_id() {
return c_id;
}
String getC_name() {
return c_name;
}
String getAddress() {
return address;
}
String getPh_no() {
return ph_no;
}
void setAddress(String address) {
this.address = address;
}
void setPh_no(String ph_no) {
this.ph_no = ph_no;
}
}
static class Product {
String item_no, name;
double price;
int qty;
// public Product(String item_no, String name) {
// this.item_no = item_no;
// this.name = name;
// }
public Product(String item_no, String name, double price, int qty) {
this.item_no = item_no;
this.name = name;
this.price = price;
this.qty = qty;
}
String getItem_no() {
return item_no;
}
String getName() {
return name;
}
double getPrice() {
return price;
}
int getQty() {
return qty;
}
void setPrice(double price) {
this.price = price;
}
void setQty(int qty) {
this.qty = qty;
}
}
}