JAVA Inventory System using .csv files (FIRST FILE) Product ID,Description,Unit
ID: 3671495 • Letter: J
Question
JAVA Inventory System using .csv files
(FIRST FILE)
Product ID,Description,Unit Price
10001,Claw Hammer 16 oz,$17.00
10002,Framing Hammer 22 oz,$55.00
10003,Framing Hammer 28 oz,$60.00
10004,Tack Hammer 12 oz,$12.00
10005,Sledge Hammer 15 lb,$35.00
10006,Sledge Hammer 20 lb,$45.00
10007,Hand Sledge Hammer 2.5 lb,$15.00
10008,Hand Sledge Hammer 5 lb,$20.00
10009,Ball Pein Hammer 24 oz,$30.00
10010,Ball Pein Hammer 32 oz,$35.00
20001,Screwdriver 4 in slotted,$6.50
20002,Screwdriver 4 in Phillips,$6.50
20003,Screwdriver 6 in slotted,$7.50
20004,Screwdriver 6 in Phillips,$7.50
20005,Screwdriver 8 in slotted,$8.50
20006,Screwdriver 8 in Phillips,$8.50
30001,Wrench Adjustable 4 in,$8.00
30002,Wrench Adjustable 6 in,$10.00
30003,Wrench Adjustable 8 in,$12.00
30004,Wrench Adjustable 10 in,$15.00
30005,Wrench Combo 3/8 in,$8.00
30006,Wrench Combo 1/2 in,$8.00
30007,Wrench Combo 5/8 in,$8.00
30008,Wrench Combo 3/4 in,$9.00
30009,Wrench Combo 7/8 in,$9.00
30010,Wrench Combo 1 in,$10.00
30011,Wrench Combo 1 1/4 in,$10.00
30012,Wrench Combo 1 1/2 in,$10.00
30013,Wrench Allen 1/16 in,$2.50
30014,Wrench Allen 1/4 in,$2.50
30015,Wrench Allen 1/8 in,$2.50
30016,Wrench Allen 3/16 in,$2.50
30017,Wrench Allen 1/4 in,$3.50
30018,Wrench Allen 5/16 in,$3.50
30019,Wrench Allen 3/8 in,$3.50
30020,Wrench Allen 7/16 in,$3.50
(SECOND FILE)
Customer ID,Product ID,Units
1,10002,4
1,10004,6
1,10008,2
1,10010,3
1,10010,3
2,10007,10
2,20003,4
2,20003,7
2,30019,1
2,30020,9
3,10004,9
3,10006,7
3,20005,5
3,30004,10
4,20004,2
4,30002,7
4,30013,6
5,20005,5
5,30006,1
5,30006,7
5,30007,2
5,30012,10
5,30015,7
5,30015,3
6,10001,5
6,20001,8
6,30007,3
6,30014,3
6,30015,6
6,30016,2
7,10001,8
7,10003,8
7,10007,5
7,10007,8
7,20005,6
7,20006,10
7,30003,4
7,30011,7
7,30014,7
7,30016,5
8,20003,1
8,30003,4
8,30010,5
8,30011,8
8,30012,1
8,30014,9
8,30016,4
8,30018,5
9,10006,1
9,10010,9
9,20005,5
9,30001,1
9,30004,9
9,30007,5
9,30009,1
9,30014,6
9,30016,5
9,30016,2
9,30020,8
10,10004,3
10,10004,7
10,10008,2
10,20001,4
10,20003,7
10,20004,6
10,20006,2
10,30001,1
10,30003,7
10,30004,1
10,30004,10
10,30005,2
10,30006,7
10,30017,10
10,30018,2
11,30004,6
12,10009,9
12,10009,7
12,10010,10
12,20005,3
12,30002,1
12,30004,2
12,30004,8
12,30013,3
12,30019,3
13,10004,10
13,10007,5
13,30001,7
13,30003,6
13,30006,2
13,30006,3
13,30007,2
13,30013,8
13,30016,8
14,10003,6
14,10004,9
14,10004,2
14,10006,8
14,10010,1
14,20003,9
14,20003,10
14,30001,8
14,30002,1
14,30013,5
14,30015,7
14,30018,1
14,30019,10
14,30020,9
15,10008,1
15,10009,3
15,20004,10
15,30010,7
15,30012,9
15,30014,7
15,30017,4
16,20004,5
16,30005,8
16,30010,7
16,30011,1
17,10004,9
17,10004,4
17,10006,5
17,10010,7
17,20001,3
17,20003,2
17,20004,7
17,30004,8
17,30010,2
17,30012,5
17,30019,8
17,30020,1
18,10008,7
18,30001,9
18,30003,10
18,30003,8
18,30006,5
18,30008,10
18,30009,7
18,30009,8
18,30015,9
18,30017,9
18,30018,7
18,30020,1
19,10001,7
19,10002,10
19,10003,3
19,10005,4
19,10010,4
19,20001,4
19,20002,1
19,20005,5
19,30006,9
19,30006,6
20,10003,7
20,10003,4
20,10004,6
20,10009,6
20,20002,6
20,20004,3
20,20005,3
20,30001,9
20,30005,2
20,30006,10
20,30008,6
20,30009,6
20,30011,10
20,30013,8
20,30013,3
20,30013,5
20,30015,1
20,30019,10
21,10002,6
21,10004,7
21,10006,3
21,10006,2
21,20002,6
21,20004,7
21,20004,7
21,30005,4
21,30006,8
21,30007,3
21,30008,6
21,30009,8
21,30014,5
21,30015,10
21,30015,9
21,30018,3
21,30019,2
21,30019,9
21,30020,1
22,10006,10
22,20003,2
22,30001,3
22,30005,5
22,30012,5
22,30015,5
22,30015,3
22,30016,2
22,30019,8
22,30019,5
Explanation / Answer
import java.io.*;
import java.util.*;
class Product{
int product_id;
String description;
double price;
public Product(int id,String des,double p){
product_id = id;
description = des;
price = p;
}
public void setID(int id){
product_id = id;
}
public int getID(){
return product_id;
}
public void setDescription(String des){
description = des;
}
public String getDescription(){
return description;
}
public void setPrice(double p){
price = p;
}
public double getPrice(){
return price;
}
public String toString(){
String s = "PRODUCT ID : "+ product_id + ' ';
s += "DESCRIPTION : " + description + ' ';
s += "PRICE : " + price + ' ';
return s;
}
}
class Sale{
int product_id;
double price;
int units;
public Sale(int id,double p,int u){
product_id = id;
price = p;
units = u;
}
public void setID(int id){
product_id = id;
}
public int getID(){
return product_id;
}
public void setPrice(double p){
price = p;
}
public double getPrice(){
return price;
}
public void setUnit(int u){
units = u;
}
public int getUnit(){
return units;
}
public String toString(){
String s = "PRODUCT ID : "+ product_id + ' ';
s += "PRICE : " + price + ' ';
s += "UNITS : " + units + ' ';
return s;
}
}
class Sales_Receipt{
int sale_id;
int product_id;
Date date;
ArrayList<Sale> ls;
public Sales_Receipt(int s,int p,Date d){
sale_id = s;
product_id = p;
date = d;
}
public int get_sale_ID(){
return sale_id;
}
public int get_product_id(){
return product_id;
}
public Date getDate(){
return date;
}
public double total(){
double total_cost = 0.0;
for (int i = 0; i < ls.size(); i++){
Sale s = ls.get(i);
total_cost += s.getPrice()*s.getUnit();
}
return total_cost;
}
public String toString(){
String s = "SALE ID : "+sale_id + ' ';
s += "PRODUCT ID : " + product_id + ' ';
s += "Date : "+date+' ';
s += "TOTAL : "+total() + ' ';
return s;
}
}
class main{
public static void main(String[] args){
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.