SlideShare a Scribd company logo
Warehouse Inventories
Objective:
Work with multiple objects and review reading data files.
Description: A wholesale distributor has six warehouses (Atlanta, Baltimore, Chicago, Denver,
Ely and Fargo) and sells five different items (identified by part number: 102, 215, 410, 525 and
711). Each warehouse may stock any or all of the five items. The company buys and sells these
items constantly. Company transaction records contain a transaction code (‘P’ for a purchase or
‘S’ for a sale) followed by an item number and the quantity (bought or sold).
The transaction records are contained in a transaction data file named Transactions.txt.
Sample transaction records: Transactions.txt
P 410 1000
S 215 120
S 711 300
|
A separate data file contains the initial status of the six warehouses at the beginning of the day
(i.e., the ending status from the night before). This data file has only six records (lines). Each
record (line) contains five numbers that show the quantity on hand for the five items in that
warehouse. This file is named Inventory.txt.
Sample status data file: Inventory.txt
500 120 60 0 350
100 230 0 50 0
0 75 0 0 220
600 50 120 300 40
210 160 30 80 50
90 50 90 200 70
|
The status data file is updated by processing the transaction records in the transaction data file
according to these rules:
1 – For a sale (‘S’) – subtract the quantity sold from the warehouse that
has the largest supply of that item on hand.
2 – For a purchase (‘P’) – add the quantity purchased to the warehouse
that has the lowest supply of that item on hand.
Instructions:
Write an object-oriented Java program to do the above inventory warehouse processing. Each of
the six warehouses should be treated as an individual object. For example, Atlanta would be an
object with each of the five part numbers as instance fields. Each of the other warehouses should
also be objects with the five part numbers as instance fields. Of course, there would be one class
which would be the main (driver) class from which these 6 objects would be created.
In the beginning of the program, the status data file (Inventory.txt) should be read and an object
for each warehouse created. The Inventory.txt data file is in the following order: the first line is
the Atlanta warehouse, the second line is the Baltimore warehouse, third Chicago, then Denver,
Ely and Fargo. After the objects are created, the transactions data file (Transactions.txt) are read
and processed.
The objects should be updated as the transaction records are read and processed.
The program should:
1 – Display the initial (beginning-of-day) status for all warehouses.
2 – Process each transaction from the transaction data file and show which
warehouse’s inventory was updated to reflect that transaction.
3 – Display the final (end-of-day) status for all warehouses.
Requirements:
The class must be named Inventory.
The main program (driver) must be named Warehouses.
A driver (main class) as well as a programmer-defined class must be used.
Submit program through the assignment tool in Moodle2.
Include a comment stating your name.
Each student must create his/her own independent program.
Warehouse Inventories
Objective:
Work with multiple objects and review reading data files.
Description: A wholesale distributor has six warehouses (Atlanta, Baltimore, Chicago, Denver,
Ely and Fargo) and sells five different items (identified by part number: 102, 215, 410, 525 and
711). Each warehouse may stock any or all of the five items. The company buys and sells these
items constantly. Company transaction records contain a transaction code (‘P’ for a purchase or
‘S’ for a sale) followed by an item number and the quantity (bought or sold).
The transaction records are contained in a transaction data file named Transactions.txt.
Sample transaction records: Transactions.txt
P 410 1000
S 215 120
S 711 300
|
A separate data file contains the initial status of the six warehouses at the beginning of the day
(i.e., the ending status from the night before). This data file has only six records (lines). Each
record (line) contains five numbers that show the quantity on hand for the five items in that
warehouse. This file is named Inventory.txt.
Sample status data file: Inventory.txt
500 120 60 0 350
100 230 0 50 0
0 75 0 0 220
600 50 120 300 40
210 160 30 80 50
90 50 90 200 70
|
The status data file is updated by processing the transaction records in the transaction data file
according to these rules:
1 – For a sale (‘S’) – subtract the quantity sold from the warehouse that
has the largest supply of that item on hand.
2 – For a purchase (‘P’) – add the quantity purchased to the warehouse
that has the lowest supply of that item on hand.
Instructions:
Write an object-oriented Java program to do the above inventory warehouse processing. Each of
the six warehouses should be treated as an individual object. For example, Atlanta would be an
object with each of the five part numbers as instance fields. Each of the other warehouses should
also be objects with the five part numbers as instance fields. Of course, there would be one class
which would be the main (driver) class from which these 6 objects would be created.
In the beginning of the program, the status data file (Inventory.txt) should be read and an object
for each warehouse created. The Inventory.txt data file is in the following order: the first line is
the Atlanta warehouse, the second line is the Baltimore warehouse, third Chicago, then Denver,
Ely and Fargo. After the objects are created, the transactions data file (Transactions.txt) are read
and processed.
The objects should be updated as the transaction records are read and processed.
The program should:
1 – Display the initial (beginning-of-day) status for all warehouses.
2 – Process each transaction from the transaction data file and show which
warehouse’s inventory was updated to reflect that transaction.
3 – Display the final (end-of-day) status for all warehouses.
Requirements:
The class must be named Inventory.
The main program (driver) must be named Warehouses.
A driver (main class) as well as a programmer-defined class must be used.
Solution
publicclass Inventory {
publicfinalstatic String[] WAREHOUSES = {"Atlanta", "Baltimore", "Chicago", "Denver",
"Ely", "Fargo"};
//Instance variables
privateint part_number_102;
privateint part_number_215;
privateint part_number_410;
privateint part_number_525;
privateint part_number_711;
/**
* Default Construtor
*/
public Inventory() {
this.part_number_102 = 0;
this.part_number_215 = 0;
this.part_number_410 = 0;
this.part_number_525 = 0;
this.part_number_711 = 0;
}
/**
* Parameterized Constructor
* @param part_number_102
* @param part_number_215
* @param part_number_410
* @param part_number_525
* @param part_number_711
*/
public Inventory(int part_number_102, int part_number_215, int part_number_410, int
part_number_525,
int part_number_711) {
this.part_number_102 = part_number_102;
this.part_number_215 = part_number_215;
this.part_number_410 = part_number_410;
this.part_number_525 = part_number_525;
this.part_number_711 = part_number_711;
}
/**
* @return the part_number_102
*/
publicint getPart_number_102() {
return part_number_102;
}
/**
* @param part_number_102 the part_number_102 to set
*/
publicvoid setPart_number_102(int part_number_102) {
this.part_number_102 = part_number_102;
}
/**
* @return the part_number_215
*/
publicint getPart_number_215() {
return part_number_215;
}
/**
* @param part_number_215 the part_number_215 to set
*/
publicvoid setPart_number_215(int part_number_215) {
this.part_number_215 = part_number_215;
}
/**
* @return the part_number_410
*/
publicint getPart_number_410() {
return part_number_410;
}
/**
* @param part_number_410 the part_number_410 to set
*/
publicvoid setPart_number_410(int part_number_410) {
this.part_number_410 = part_number_410;
}
/**
* @return the part_number_525
*/
publicint getPart_number_525() {
return part_number_525;
}
/**
* @param part_number_525 the part_number_525 to set
*/
publicvoid setPart_number_525(int part_number_525) {
this.part_number_525 = part_number_525;
}
/**
* @return the part_number_711
*/
publicint getPart_number_711() {
return part_number_711;
}
/**
* @param part_number_711 the part_number_711 to set
*/
publicvoid setPart_number_711(int part_number_711) {
this.part_number_711 = part_number_711;
}
@Override
public String toString() {
System.out.printf("%6s %6s", "Part #", "Quantity");
System.out.printf(" %-6s %6d", "102", this.part_number_102);
System.out.printf(" %-6s %6d", "215", this.part_number_215);
System.out.printf(" %-6s %6d", "410", this.part_number_410);
System.out.printf(" %-6s %6d", "525", this.part_number_525);
System.out.printf(" %-6s %6d", "711", this.part_number_711);
return "";
}
/**
* Gets the warehouse name from the WAREHOUSE static final String array
* based on the index passed as the parameter
* @param index
* @return
*/
publicstatic String getWarehouseName(int index) {
returnWAREHOUSES[index];
}
/**
* Gets the total supply for a part number
* @param index
* @return
*/
publicint getSupply(int partNum) {
int supply = 0;
switch(partNum) {
case 102:
supply = this.getPart_number_102();
break;
case 215:
supply = this.getPart_number_215();
break;
case 410:
supply = this.getPart_number_410();
break;
case 525:
supply = this.getPart_number_525();
break;
case 711:
supply = this.getPart_number_711();
}
return supply;
}
}
-------
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
publicclass Warehouses {
//File names
privatestaticfinal String INVENTORY_FILE = "Inventory.txt";
privatestaticfinal String TRANSACTION_FILE = "Transactions.txt";
privatestaticfinal String EOF_CHAR = "|";
/**
* Read inventory.txt file
* @param inventory
* @return
*/
publicstatic Inventory[] getInventory(Inventory[] inventory) {
BufferedReader br = null;
try {
FileReader reader = new FileReader(new File(INVENTORY_FILE));
br = new BufferedReader(reader);
String line;
int index = 0;
while(!(line = br.readLine()).equalsIgnoreCase(EOF_CHAR)) {
String[] rec = line.split(" ");
//Set quantity for each part number of each warehouse
inventory[index]= new Inventory(Integer.parseInt(rec[0]), Integer.parseInt(rec[1]),
Integer.parseInt(rec[2]), Integer.parseInt(rec[3]),
Integer.parseInt(rec[4]));
index += 1;
}
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(br != null)
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return inventory;
}
/**
* Get warehouse with the largest supply for a part number
* @param inventory
* @return
*/
publicstatic Inventory[] updateLargestSupply(Inventory[] inventory, String[] rec) {
int partNum = Integer.parseInt(rec[1]);
int max = inventory[0].getSupply(partNum);
int index = 0;
for(int i = 1 ; i < inventory.length ; i++) {
if(inventory[i].getSupply(partNum) > max) {
index = i;
max = inventory[index].getSupply(partNum);
}
}
//Update supply
System.out.println("Updating the quantity of part number " + rec[1] + " at warehouse " +
Inventory.getWarehouseName(index));
switch(partNum) {
case 102:
inventory[index].setPart_number_102(max - Integer.parseInt(rec[2]));
break;
case 215:
inventory[index].setPart_number_215(max - Integer.parseInt(rec[2]));
break;
case 410:
inventory[index].setPart_number_410(max - Integer.parseInt(rec[2]));
break;
case 525:
inventory[index].setPart_number_525(max - Integer.parseInt(rec[2]));
break;
case 711:
inventory[index].setPart_number_711(max - Integer.parseInt(rec[2]));
}
return inventory;
}
/**
* Get warehouse with the lowest supply for a part number
* @param inventory
* @return
*/
publicstatic Inventory[] updateLowestSupply(Inventory[] inventory, String[] rec) {
int partNum = Integer.parseInt(rec[1]);
int min = inventory[0].getSupply(partNum);
int index = 0;
for(int i = 1 ; i < inventory.length ; i++) {
if(inventory[i].getSupply(partNum) < min) {
index = i;
min = inventory[index].getSupply(partNum);
}
}
//Update supply
System.out.println("Updating the quantity of part number " + rec[1] + " at warehouse " +
Inventory.getWarehouseName(index));
switch(partNum) {
case 102:
inventory[index].setPart_number_102(min + Integer.parseInt(rec[2]));
break;
case 215:
inventory[index].setPart_number_215(min + Integer.parseInt(rec[2]));
break;
case 410:
inventory[index].setPart_number_410(min + Integer.parseInt(rec[2]));
break;
case 525:
inventory[index].setPart_number_525(min + Integer.parseInt(rec[2]));
break;
case 711:
inventory[index].setPart_number_711(min + Integer.parseInt(rec[2]));
}
return inventory;
}
/**
* Read transactions.txt file and update the inventory array
* @param inventory
* @return
*/
publicstatic Inventory[] processTransaction(Inventory[] inventory) {
BufferedReader br = null;
try {
FileReader reader = new FileReader(new File(TRANSACTION_FILE));
br = new BufferedReader(reader);
String line;
while(!(line = br.readLine()).equalsIgnoreCase(EOF_CHAR)) {
String[] rec = line.split(" ");
if(rec[0].equalsIgnoreCase("P")) {
System.out.println();
System.out.println("Reading transaction for Purchase of " + rec[2] + " quantites of part number
" + rec[1]);
updateLowestSupply(inventory, rec);
} elseif(rec[0].equalsIgnoreCase("S")) {
System.out.println();
System.out.println("Reading transaction for Sale of " + rec[2] + " quantites of part number " +
rec[1]);
updateLargestSupply(inventory, rec);
}
}
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(br != null)
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return inventory;
}
publicstaticvoid main(String[] args) {
//Create an array of Inventory for each of the warehouses
//mentioned in the WAREHOUSES string array
Inventory[] inventory = new Inventory[Inventory.WAREHOUSES.length];
//Display the initial (beginning-of-day) status for all warehouses.
getInventory(inventory);
System.out.println("***Initial (beginning-of-day) status for all warehouses***");
for(int i = 0 ; i < inventory.length ; i++) {
System.out.println("Inventory details of " + Inventory.getWarehouseName(i));
System.out.println(inventory[i]);
}
//Process each transaction from the transaction data file and show which
//warehouse’s inventory was updated to reflect that transaction.
processTransaction(inventory);
//Display the final (end-of-day) status for all warehouses.
System.out.println(" ***Final (end-of-day) status for all warehouses***");
for(int i = 0 ; i < inventory.length ; i++) {
System.out.println("Inventory details of " + Inventory.getWarehouseName(i));
System.out.println(inventory[i]);
}
}
}
SAMPLE OUTPUT:
***Initial (beginning-of-day) status for all warehouses***
Inventory details of Atlanta
Part # Quantity
102 500
215 120
410 60
525 0
711 350
Inventory details of Baltimore
Part # Quantity
102 100
215 230
410 0
525 50
711 0
Inventory details of Chicago
Part # Quantity
102 0
215 75
410 0
525 0
711 220
Inventory details of Denver
Part # Quantity
102 600
215 50
410 120
525 300
711 40
Inventory details of Ely
Part # Quantity
102 210
215 160
410 30
525 80
711 50
Inventory details of Fargo
Part # Quantity
102 90
215 50
410 90
525 200
711 70
Reading transaction for Purchase of 1000 quantites of part number 410
Updating the quantity of part number 410 at warehouse Baltimore
Reading transaction for Sale of 120 quantites of part number 215
Updating the quantity of part number 215 at warehouse Baltimore
Reading transaction for Sale of 300 quantites of part number 711
Updating the quantity of part number 711 at warehouse Atlanta
***Final (end-of-day) status for all warehouses***
Inventory details of Atlanta
Part # Quantity
102 500
215 120
410 60
525 0
711 50
Inventory details of Baltimore
Part # Quantity
102 100
215 110
410 1000
525 50
711 0
Inventory details of Chicago
Part # Quantity
102 0
215 75
410 0
525 0
711 220
Inventory details of Denver
Part # Quantity
102 600
215 50
410 120
525 300
711 40
Inventory details of Ely
Part # Quantity
102 210
215 160
410 30
525 80
711 50
Inventory details of Fargo
Part # Quantity
102 90
215 50
410 90
525 200
711 70

More Related Content

Similar to Warehouse InventoriesObjectiveWork with multiple objects and re.pdf

The program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdfThe program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdf
ivylinvaydak64229
 
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdfReaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
fashionbigchennai
 
Inventory in Oracle apps
Inventory in Oracle apps Inventory in Oracle apps
Inventory in Oracle apps
gbalagee
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdf
AlanSmDDyerl
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and FunctionsJake Bond
 
Oracle Inventory r12 lot and serial control.ppt
Oracle Inventory r12 lot and serial control.pptOracle Inventory r12 lot and serial control.ppt
Oracle Inventory r12 lot and serial control.ppt
ahosainy
 
PC Inventory Control Training 11-2010
PC Inventory Control Training 11-2010PC Inventory Control Training 11-2010
PC Inventory Control Training 11-2010
LeapAce
 
Cis515
Cis515Cis515
Cis515
Tracy Clark
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
cargillfilberto
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
drandy1
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
monicafrancis71118
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docx
VictormxrPiperc
 
Companies and people often buy and sell stocks. Often they buy th.pdf
Companies and people often buy and sell stocks. Often they buy th.pdfCompanies and people often buy and sell stocks. Often they buy th.pdf
Companies and people often buy and sell stocks. Often they buy th.pdf
artimagein
 
Automating a Vendor File Load Process with Perl and Shell Scripting
Automating a Vendor File Load Process with Perl and Shell ScriptingAutomating a Vendor File Load Process with Perl and Shell Scripting
Automating a Vendor File Load Process with Perl and Shell Scripting
Roy Zimmer
 
Reports in Horizon
Reports in HorizonReports in Horizon
Reports in HorizonJohnny Pe
 
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docxProcess Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
stilliegeorgiana
 
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Massimo Cenci
 
Uni v2 eth-dai analysis
Uni v2 eth-dai analysisUni v2 eth-dai analysis
Uni v2 eth-dai analysis
JonnyHimalaya
 

Similar to Warehouse InventoriesObjectiveWork with multiple objects and re.pdf (20)

The program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdfThe program will read the file like this, java homework6Bank sma.pdf
The program will read the file like this, java homework6Bank sma.pdf
 
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdfReaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
 
Inventory in Oracle apps
Inventory in Oracle apps Inventory in Oracle apps
Inventory in Oracle apps
 
show code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdfshow code and all classes with full implementation for these Program S.pdf
show code and all classes with full implementation for these Program S.pdf
 
Storage Classes and Functions
Storage Classes and FunctionsStorage Classes and Functions
Storage Classes and Functions
 
Oracle Inventory r12 lot and serial control.ppt
Oracle Inventory r12 lot and serial control.pptOracle Inventory r12 lot and serial control.ppt
Oracle Inventory r12 lot and serial control.ppt
 
PC Inventory Control Training 11-2010
PC Inventory Control Training 11-2010PC Inventory Control Training 11-2010
PC Inventory Control Training 11-2010
 
Cis515
Cis515Cis515
Cis515
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docxCOMM 166 Final Research Proposal GuidelinesThe proposal should.docx
COMM 166 Final Research Proposal GuidelinesThe proposal should.docx
 
WH_PREVIEW_ENG
WH_PREVIEW_ENGWH_PREVIEW_ENG
WH_PREVIEW_ENG
 
Program Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docxProgram Specifications Develop an inventory management system for an e.docx
Program Specifications Develop an inventory management system for an e.docx
 
Companies and people often buy and sell stocks. Often they buy th.pdf
Companies and people often buy and sell stocks. Often they buy th.pdfCompanies and people often buy and sell stocks. Often they buy th.pdf
Companies and people often buy and sell stocks. Often they buy th.pdf
 
Automating a Vendor File Load Process with Perl and Shell Scripting
Automating a Vendor File Load Process with Perl and Shell ScriptingAutomating a Vendor File Load Process with Perl and Shell Scripting
Automating a Vendor File Load Process with Perl and Shell Scripting
 
Bdc
BdcBdc
Bdc
 
Reports in Horizon
Reports in HorizonReports in Horizon
Reports in Horizon
 
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docxProcess Synchronization Producer-Consumer ProblemThe purpose o.docx
Process Synchronization Producer-Consumer ProblemThe purpose o.docx
 
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
Recipe 16 of Data Warehouse and Business Intelligence - The monitoring of the...
 
Uni v2 eth-dai analysis
Uni v2 eth-dai analysisUni v2 eth-dai analysis
Uni v2 eth-dai analysis
 

More from anandacorp

You shuffle a deck and then flip cardsuntil an ace appears. What is .pdf
You shuffle a deck and then flip cardsuntil an ace appears. What is .pdfYou shuffle a deck and then flip cardsuntil an ace appears. What is .pdf
You shuffle a deck and then flip cardsuntil an ace appears. What is .pdf
anandacorp
 
you stock a poond with lillys that double in size everyday. it takes.pdf
you stock a poond with lillys that double in size everyday. it takes.pdfyou stock a poond with lillys that double in size everyday. it takes.pdf
you stock a poond with lillys that double in size everyday. it takes.pdf
anandacorp
 
We all know what the unit circle centered at the origin is in Euclid.pdf
We all know what the unit circle centered at the origin is in Euclid.pdfWe all know what the unit circle centered at the origin is in Euclid.pdf
We all know what the unit circle centered at the origin is in Euclid.pdf
anandacorp
 
ways a firm can restructure a businessSolutionRestructuring ca.pdf
ways a firm can restructure a businessSolutionRestructuring ca.pdfways a firm can restructure a businessSolutionRestructuring ca.pdf
ways a firm can restructure a businessSolutionRestructuring ca.pdf
anandacorp
 
Water in the Niagra river approaches the falls at a velocity of 8km.pdf
Water in the Niagra river approaches the falls at a velocity of 8km.pdfWater in the Niagra river approaches the falls at a velocity of 8km.pdf
Water in the Niagra river approaches the falls at a velocity of 8km.pdf
anandacorp
 
Watch Zipcars Planning1) Part of zipcars plans include expans.pdf
Watch Zipcars Planning1) Part of zipcars plans include expans.pdfWatch Zipcars Planning1) Part of zipcars plans include expans.pdf
Watch Zipcars Planning1) Part of zipcars plans include expans.pdf
anandacorp
 
Water chemistry help please! Show all steps.Two waters are in equi.pdf
Water chemistry help please! Show all steps.Two waters are in equi.pdfWater chemistry help please! Show all steps.Two waters are in equi.pdf
Water chemistry help please! Show all steps.Two waters are in equi.pdf
anandacorp
 
watch the Frontline documentary Inside the Meltdown. As you watch th.pdf
watch the Frontline documentary Inside the Meltdown. As you watch th.pdfwatch the Frontline documentary Inside the Meltdown. As you watch th.pdf
watch the Frontline documentary Inside the Meltdown. As you watch th.pdf
anandacorp
 
Wastewater Treatment class(Civil Engineering)True or False Q.pdf
Wastewater Treatment class(Civil Engineering)True or False Q.pdfWastewater Treatment class(Civil Engineering)True or False Q.pdf
Wastewater Treatment class(Civil Engineering)True or False Q.pdf
anandacorp
 
Wastewater Treatment class(Civil Engineering) 254 La pressure .pdf
Wastewater Treatment class(Civil Engineering) 254 La pressure .pdfWastewater Treatment class(Civil Engineering) 254 La pressure .pdf
Wastewater Treatment class(Civil Engineering) 254 La pressure .pdf
anandacorp
 
Was wondering how I would put this question into MS Excel I see the.pdf
Was wondering how I would put this question into MS Excel I see the.pdfWas wondering how I would put this question into MS Excel I see the.pdf
Was wondering how I would put this question into MS Excel I see the.pdf
anandacorp
 
Was there a production gap when Kennedy assumed the presidency in Ja.pdf
Was there a production gap when Kennedy assumed the presidency in Ja.pdfWas there a production gap when Kennedy assumed the presidency in Ja.pdf
Was there a production gap when Kennedy assumed the presidency in Ja.pdf
anandacorp
 
VI. Suppose 5 of the population have a certain disease. A laborator.pdf
VI. Suppose 5 of the population have a certain disease. A laborator.pdfVI. Suppose 5 of the population have a certain disease. A laborator.pdf
VI. Suppose 5 of the population have a certain disease. A laborator.pdf
anandacorp
 
Warning when using IRR, UNLIKE NPV, you include year 0 in the value.pdf
Warning when using IRR, UNLIKE NPV, you include year 0 in the value.pdfWarning when using IRR, UNLIKE NPV, you include year 0 in the value.pdf
Warning when using IRR, UNLIKE NPV, you include year 0 in the value.pdf
anandacorp
 
Walt Disney Company is famed for its creativity, strong global brand.pdf
Walt Disney Company is famed for its creativity, strong global brand.pdfWalt Disney Company is famed for its creativity, strong global brand.pdf
Walt Disney Company is famed for its creativity, strong global brand.pdf
anandacorp
 
W Company is a white goods manufacturer that has been particularly h.pdf
W Company is a white goods manufacturer that has been particularly h.pdfW Company is a white goods manufacturer that has been particularly h.pdf
W Company is a white goods manufacturer that has been particularly h.pdf
anandacorp
 
Voter attitudes - Suggest properties of voter attitudes that can be .pdf
Voter attitudes - Suggest properties of voter attitudes that can be .pdfVoter attitudes - Suggest properties of voter attitudes that can be .pdf
Voter attitudes - Suggest properties of voter attitudes that can be .pdf
anandacorp
 
Violent vs. Non-violent solutions. Violent solutions are temporary s.pdf
Violent vs. Non-violent solutions. Violent solutions are temporary s.pdfViolent vs. Non-violent solutions. Violent solutions are temporary s.pdf
Violent vs. Non-violent solutions. Violent solutions are temporary s.pdf
anandacorp
 
Violating an Apartment Lease occurs when a tenant does something pro.pdf
Violating an Apartment Lease occurs when a tenant does something pro.pdfViolating an Apartment Lease occurs when a tenant does something pro.pdf
Violating an Apartment Lease occurs when a tenant does something pro.pdf
anandacorp
 
Very recently, the GBP has been raising against the Euro. I understa.pdf
Very recently, the GBP has been raising against the Euro. I understa.pdfVery recently, the GBP has been raising against the Euro. I understa.pdf
Very recently, the GBP has been raising against the Euro. I understa.pdf
anandacorp
 

More from anandacorp (20)

You shuffle a deck and then flip cardsuntil an ace appears. What is .pdf
You shuffle a deck and then flip cardsuntil an ace appears. What is .pdfYou shuffle a deck and then flip cardsuntil an ace appears. What is .pdf
You shuffle a deck and then flip cardsuntil an ace appears. What is .pdf
 
you stock a poond with lillys that double in size everyday. it takes.pdf
you stock a poond with lillys that double in size everyday. it takes.pdfyou stock a poond with lillys that double in size everyday. it takes.pdf
you stock a poond with lillys that double in size everyday. it takes.pdf
 
We all know what the unit circle centered at the origin is in Euclid.pdf
We all know what the unit circle centered at the origin is in Euclid.pdfWe all know what the unit circle centered at the origin is in Euclid.pdf
We all know what the unit circle centered at the origin is in Euclid.pdf
 
ways a firm can restructure a businessSolutionRestructuring ca.pdf
ways a firm can restructure a businessSolutionRestructuring ca.pdfways a firm can restructure a businessSolutionRestructuring ca.pdf
ways a firm can restructure a businessSolutionRestructuring ca.pdf
 
Water in the Niagra river approaches the falls at a velocity of 8km.pdf
Water in the Niagra river approaches the falls at a velocity of 8km.pdfWater in the Niagra river approaches the falls at a velocity of 8km.pdf
Water in the Niagra river approaches the falls at a velocity of 8km.pdf
 
Watch Zipcars Planning1) Part of zipcars plans include expans.pdf
Watch Zipcars Planning1) Part of zipcars plans include expans.pdfWatch Zipcars Planning1) Part of zipcars plans include expans.pdf
Watch Zipcars Planning1) Part of zipcars plans include expans.pdf
 
Water chemistry help please! Show all steps.Two waters are in equi.pdf
Water chemistry help please! Show all steps.Two waters are in equi.pdfWater chemistry help please! Show all steps.Two waters are in equi.pdf
Water chemistry help please! Show all steps.Two waters are in equi.pdf
 
watch the Frontline documentary Inside the Meltdown. As you watch th.pdf
watch the Frontline documentary Inside the Meltdown. As you watch th.pdfwatch the Frontline documentary Inside the Meltdown. As you watch th.pdf
watch the Frontline documentary Inside the Meltdown. As you watch th.pdf
 
Wastewater Treatment class(Civil Engineering)True or False Q.pdf
Wastewater Treatment class(Civil Engineering)True or False Q.pdfWastewater Treatment class(Civil Engineering)True or False Q.pdf
Wastewater Treatment class(Civil Engineering)True or False Q.pdf
 
Wastewater Treatment class(Civil Engineering) 254 La pressure .pdf
Wastewater Treatment class(Civil Engineering) 254 La pressure .pdfWastewater Treatment class(Civil Engineering) 254 La pressure .pdf
Wastewater Treatment class(Civil Engineering) 254 La pressure .pdf
 
Was wondering how I would put this question into MS Excel I see the.pdf
Was wondering how I would put this question into MS Excel I see the.pdfWas wondering how I would put this question into MS Excel I see the.pdf
Was wondering how I would put this question into MS Excel I see the.pdf
 
Was there a production gap when Kennedy assumed the presidency in Ja.pdf
Was there a production gap when Kennedy assumed the presidency in Ja.pdfWas there a production gap when Kennedy assumed the presidency in Ja.pdf
Was there a production gap when Kennedy assumed the presidency in Ja.pdf
 
VI. Suppose 5 of the population have a certain disease. A laborator.pdf
VI. Suppose 5 of the population have a certain disease. A laborator.pdfVI. Suppose 5 of the population have a certain disease. A laborator.pdf
VI. Suppose 5 of the population have a certain disease. A laborator.pdf
 
Warning when using IRR, UNLIKE NPV, you include year 0 in the value.pdf
Warning when using IRR, UNLIKE NPV, you include year 0 in the value.pdfWarning when using IRR, UNLIKE NPV, you include year 0 in the value.pdf
Warning when using IRR, UNLIKE NPV, you include year 0 in the value.pdf
 
Walt Disney Company is famed for its creativity, strong global brand.pdf
Walt Disney Company is famed for its creativity, strong global brand.pdfWalt Disney Company is famed for its creativity, strong global brand.pdf
Walt Disney Company is famed for its creativity, strong global brand.pdf
 
W Company is a white goods manufacturer that has been particularly h.pdf
W Company is a white goods manufacturer that has been particularly h.pdfW Company is a white goods manufacturer that has been particularly h.pdf
W Company is a white goods manufacturer that has been particularly h.pdf
 
Voter attitudes - Suggest properties of voter attitudes that can be .pdf
Voter attitudes - Suggest properties of voter attitudes that can be .pdfVoter attitudes - Suggest properties of voter attitudes that can be .pdf
Voter attitudes - Suggest properties of voter attitudes that can be .pdf
 
Violent vs. Non-violent solutions. Violent solutions are temporary s.pdf
Violent vs. Non-violent solutions. Violent solutions are temporary s.pdfViolent vs. Non-violent solutions. Violent solutions are temporary s.pdf
Violent vs. Non-violent solutions. Violent solutions are temporary s.pdf
 
Violating an Apartment Lease occurs when a tenant does something pro.pdf
Violating an Apartment Lease occurs when a tenant does something pro.pdfViolating an Apartment Lease occurs when a tenant does something pro.pdf
Violating an Apartment Lease occurs when a tenant does something pro.pdf
 
Very recently, the GBP has been raising against the Euro. I understa.pdf
Very recently, the GBP has been raising against the Euro. I understa.pdfVery recently, the GBP has been raising against the Euro. I understa.pdf
Very recently, the GBP has been raising against the Euro. I understa.pdf
 

Recently uploaded

Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
timhan337
 

Recently uploaded (20)

Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Honest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptxHonest Reviews of Tim Han LMA Course Program.pptx
Honest Reviews of Tim Han LMA Course Program.pptx
 

Warehouse InventoriesObjectiveWork with multiple objects and re.pdf

  • 1. Warehouse Inventories Objective: Work with multiple objects and review reading data files. Description: A wholesale distributor has six warehouses (Atlanta, Baltimore, Chicago, Denver, Ely and Fargo) and sells five different items (identified by part number: 102, 215, 410, 525 and 711). Each warehouse may stock any or all of the five items. The company buys and sells these items constantly. Company transaction records contain a transaction code (‘P’ for a purchase or ‘S’ for a sale) followed by an item number and the quantity (bought or sold). The transaction records are contained in a transaction data file named Transactions.txt. Sample transaction records: Transactions.txt P 410 1000 S 215 120 S 711 300 | A separate data file contains the initial status of the six warehouses at the beginning of the day (i.e., the ending status from the night before). This data file has only six records (lines). Each record (line) contains five numbers that show the quantity on hand for the five items in that warehouse. This file is named Inventory.txt. Sample status data file: Inventory.txt 500 120 60 0 350 100 230 0 50 0 0 75 0 0 220 600 50 120 300 40 210 160 30 80 50 90 50 90 200 70 | The status data file is updated by processing the transaction records in the transaction data file according to these rules: 1 – For a sale (‘S’) – subtract the quantity sold from the warehouse that has the largest supply of that item on hand. 2 – For a purchase (‘P’) – add the quantity purchased to the warehouse that has the lowest supply of that item on hand. Instructions: Write an object-oriented Java program to do the above inventory warehouse processing. Each of the six warehouses should be treated as an individual object. For example, Atlanta would be an
  • 2. object with each of the five part numbers as instance fields. Each of the other warehouses should also be objects with the five part numbers as instance fields. Of course, there would be one class which would be the main (driver) class from which these 6 objects would be created. In the beginning of the program, the status data file (Inventory.txt) should be read and an object for each warehouse created. The Inventory.txt data file is in the following order: the first line is the Atlanta warehouse, the second line is the Baltimore warehouse, third Chicago, then Denver, Ely and Fargo. After the objects are created, the transactions data file (Transactions.txt) are read and processed. The objects should be updated as the transaction records are read and processed. The program should: 1 – Display the initial (beginning-of-day) status for all warehouses. 2 – Process each transaction from the transaction data file and show which warehouse’s inventory was updated to reflect that transaction. 3 – Display the final (end-of-day) status for all warehouses. Requirements: The class must be named Inventory. The main program (driver) must be named Warehouses. A driver (main class) as well as a programmer-defined class must be used. Submit program through the assignment tool in Moodle2. Include a comment stating your name. Each student must create his/her own independent program. Warehouse Inventories Objective: Work with multiple objects and review reading data files. Description: A wholesale distributor has six warehouses (Atlanta, Baltimore, Chicago, Denver, Ely and Fargo) and sells five different items (identified by part number: 102, 215, 410, 525 and 711). Each warehouse may stock any or all of the five items. The company buys and sells these items constantly. Company transaction records contain a transaction code (‘P’ for a purchase or ‘S’ for a sale) followed by an item number and the quantity (bought or sold). The transaction records are contained in a transaction data file named Transactions.txt. Sample transaction records: Transactions.txt P 410 1000 S 215 120 S 711 300 | A separate data file contains the initial status of the six warehouses at the beginning of the day
  • 3. (i.e., the ending status from the night before). This data file has only six records (lines). Each record (line) contains five numbers that show the quantity on hand for the five items in that warehouse. This file is named Inventory.txt. Sample status data file: Inventory.txt 500 120 60 0 350 100 230 0 50 0 0 75 0 0 220 600 50 120 300 40 210 160 30 80 50 90 50 90 200 70 | The status data file is updated by processing the transaction records in the transaction data file according to these rules: 1 – For a sale (‘S’) – subtract the quantity sold from the warehouse that has the largest supply of that item on hand. 2 – For a purchase (‘P’) – add the quantity purchased to the warehouse that has the lowest supply of that item on hand. Instructions: Write an object-oriented Java program to do the above inventory warehouse processing. Each of the six warehouses should be treated as an individual object. For example, Atlanta would be an object with each of the five part numbers as instance fields. Each of the other warehouses should also be objects with the five part numbers as instance fields. Of course, there would be one class which would be the main (driver) class from which these 6 objects would be created. In the beginning of the program, the status data file (Inventory.txt) should be read and an object for each warehouse created. The Inventory.txt data file is in the following order: the first line is the Atlanta warehouse, the second line is the Baltimore warehouse, third Chicago, then Denver, Ely and Fargo. After the objects are created, the transactions data file (Transactions.txt) are read and processed. The objects should be updated as the transaction records are read and processed. The program should: 1 – Display the initial (beginning-of-day) status for all warehouses. 2 – Process each transaction from the transaction data file and show which warehouse’s inventory was updated to reflect that transaction. 3 – Display the final (end-of-day) status for all warehouses. Requirements: The class must be named Inventory.
  • 4. The main program (driver) must be named Warehouses. A driver (main class) as well as a programmer-defined class must be used. Solution publicclass Inventory { publicfinalstatic String[] WAREHOUSES = {"Atlanta", "Baltimore", "Chicago", "Denver", "Ely", "Fargo"}; //Instance variables privateint part_number_102; privateint part_number_215; privateint part_number_410; privateint part_number_525; privateint part_number_711; /** * Default Construtor */ public Inventory() { this.part_number_102 = 0; this.part_number_215 = 0; this.part_number_410 = 0; this.part_number_525 = 0; this.part_number_711 = 0; } /** * Parameterized Constructor * @param part_number_102 * @param part_number_215 * @param part_number_410 * @param part_number_525 * @param part_number_711 */ public Inventory(int part_number_102, int part_number_215, int part_number_410, int part_number_525, int part_number_711) { this.part_number_102 = part_number_102;
  • 5. this.part_number_215 = part_number_215; this.part_number_410 = part_number_410; this.part_number_525 = part_number_525; this.part_number_711 = part_number_711; } /** * @return the part_number_102 */ publicint getPart_number_102() { return part_number_102; } /** * @param part_number_102 the part_number_102 to set */ publicvoid setPart_number_102(int part_number_102) { this.part_number_102 = part_number_102; } /** * @return the part_number_215 */ publicint getPart_number_215() { return part_number_215; } /** * @param part_number_215 the part_number_215 to set */ publicvoid setPart_number_215(int part_number_215) { this.part_number_215 = part_number_215; } /** * @return the part_number_410 */ publicint getPart_number_410() { return part_number_410; } /**
  • 6. * @param part_number_410 the part_number_410 to set */ publicvoid setPart_number_410(int part_number_410) { this.part_number_410 = part_number_410; } /** * @return the part_number_525 */ publicint getPart_number_525() { return part_number_525; } /** * @param part_number_525 the part_number_525 to set */ publicvoid setPart_number_525(int part_number_525) { this.part_number_525 = part_number_525; } /** * @return the part_number_711 */ publicint getPart_number_711() { return part_number_711; } /** * @param part_number_711 the part_number_711 to set */ publicvoid setPart_number_711(int part_number_711) { this.part_number_711 = part_number_711; } @Override public String toString() { System.out.printf("%6s %6s", "Part #", "Quantity"); System.out.printf(" %-6s %6d", "102", this.part_number_102); System.out.printf(" %-6s %6d", "215", this.part_number_215); System.out.printf(" %-6s %6d", "410", this.part_number_410); System.out.printf(" %-6s %6d", "525", this.part_number_525);
  • 7. System.out.printf(" %-6s %6d", "711", this.part_number_711); return ""; } /** * Gets the warehouse name from the WAREHOUSE static final String array * based on the index passed as the parameter * @param index * @return */ publicstatic String getWarehouseName(int index) { returnWAREHOUSES[index]; } /** * Gets the total supply for a part number * @param index * @return */ publicint getSupply(int partNum) { int supply = 0; switch(partNum) { case 102: supply = this.getPart_number_102(); break; case 215: supply = this.getPart_number_215(); break; case 410: supply = this.getPart_number_410(); break; case 525: supply = this.getPart_number_525(); break; case 711: supply = this.getPart_number_711(); } return supply;
  • 8. } } ------- import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; publicclass Warehouses { //File names privatestaticfinal String INVENTORY_FILE = "Inventory.txt"; privatestaticfinal String TRANSACTION_FILE = "Transactions.txt"; privatestaticfinal String EOF_CHAR = "|"; /** * Read inventory.txt file * @param inventory * @return */ publicstatic Inventory[] getInventory(Inventory[] inventory) { BufferedReader br = null; try { FileReader reader = new FileReader(new File(INVENTORY_FILE)); br = new BufferedReader(reader); String line; int index = 0; while(!(line = br.readLine()).equalsIgnoreCase(EOF_CHAR)) { String[] rec = line.split(" "); //Set quantity for each part number of each warehouse inventory[index]= new Inventory(Integer.parseInt(rec[0]), Integer.parseInt(rec[1]), Integer.parseInt(rec[2]), Integer.parseInt(rec[3]), Integer.parseInt(rec[4])); index += 1; } } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } catch (IOException ioe) {
  • 9. ioe.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { try { if(br != null) br.close(); } catch (IOException e) { e.printStackTrace(); } } return inventory; } /** * Get warehouse with the largest supply for a part number * @param inventory * @return */ publicstatic Inventory[] updateLargestSupply(Inventory[] inventory, String[] rec) { int partNum = Integer.parseInt(rec[1]); int max = inventory[0].getSupply(partNum); int index = 0; for(int i = 1 ; i < inventory.length ; i++) { if(inventory[i].getSupply(partNum) > max) { index = i; max = inventory[index].getSupply(partNum); } } //Update supply System.out.println("Updating the quantity of part number " + rec[1] + " at warehouse " + Inventory.getWarehouseName(index)); switch(partNum) { case 102: inventory[index].setPart_number_102(max - Integer.parseInt(rec[2])); break; case 215:
  • 10. inventory[index].setPart_number_215(max - Integer.parseInt(rec[2])); break; case 410: inventory[index].setPart_number_410(max - Integer.parseInt(rec[2])); break; case 525: inventory[index].setPart_number_525(max - Integer.parseInt(rec[2])); break; case 711: inventory[index].setPart_number_711(max - Integer.parseInt(rec[2])); } return inventory; } /** * Get warehouse with the lowest supply for a part number * @param inventory * @return */ publicstatic Inventory[] updateLowestSupply(Inventory[] inventory, String[] rec) { int partNum = Integer.parseInt(rec[1]); int min = inventory[0].getSupply(partNum); int index = 0; for(int i = 1 ; i < inventory.length ; i++) { if(inventory[i].getSupply(partNum) < min) { index = i; min = inventory[index].getSupply(partNum); } } //Update supply System.out.println("Updating the quantity of part number " + rec[1] + " at warehouse " + Inventory.getWarehouseName(index)); switch(partNum) { case 102: inventory[index].setPart_number_102(min + Integer.parseInt(rec[2])); break; case 215:
  • 11. inventory[index].setPart_number_215(min + Integer.parseInt(rec[2])); break; case 410: inventory[index].setPart_number_410(min + Integer.parseInt(rec[2])); break; case 525: inventory[index].setPart_number_525(min + Integer.parseInt(rec[2])); break; case 711: inventory[index].setPart_number_711(min + Integer.parseInt(rec[2])); } return inventory; } /** * Read transactions.txt file and update the inventory array * @param inventory * @return */ publicstatic Inventory[] processTransaction(Inventory[] inventory) { BufferedReader br = null; try { FileReader reader = new FileReader(new File(TRANSACTION_FILE)); br = new BufferedReader(reader); String line; while(!(line = br.readLine()).equalsIgnoreCase(EOF_CHAR)) { String[] rec = line.split(" "); if(rec[0].equalsIgnoreCase("P")) { System.out.println(); System.out.println("Reading transaction for Purchase of " + rec[2] + " quantites of part number " + rec[1]); updateLowestSupply(inventory, rec); } elseif(rec[0].equalsIgnoreCase("S")) { System.out.println(); System.out.println("Reading transaction for Sale of " + rec[2] + " quantites of part number " + rec[1]); updateLargestSupply(inventory, rec);
  • 12. } } } catch (FileNotFoundException fnfe) { fnfe.printStackTrace(); } catch (IOException ioe) { ioe.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } finally { try { if(br != null) br.close(); } catch (IOException e) { e.printStackTrace(); } } return inventory; } publicstaticvoid main(String[] args) { //Create an array of Inventory for each of the warehouses //mentioned in the WAREHOUSES string array Inventory[] inventory = new Inventory[Inventory.WAREHOUSES.length]; //Display the initial (beginning-of-day) status for all warehouses. getInventory(inventory); System.out.println("***Initial (beginning-of-day) status for all warehouses***"); for(int i = 0 ; i < inventory.length ; i++) { System.out.println("Inventory details of " + Inventory.getWarehouseName(i)); System.out.println(inventory[i]); } //Process each transaction from the transaction data file and show which //warehouse’s inventory was updated to reflect that transaction. processTransaction(inventory); //Display the final (end-of-day) status for all warehouses. System.out.println(" ***Final (end-of-day) status for all warehouses***"); for(int i = 0 ; i < inventory.length ; i++) { System.out.println("Inventory details of " + Inventory.getWarehouseName(i));
  • 13. System.out.println(inventory[i]); } } } SAMPLE OUTPUT: ***Initial (beginning-of-day) status for all warehouses*** Inventory details of Atlanta Part # Quantity 102 500 215 120 410 60 525 0 711 350 Inventory details of Baltimore Part # Quantity 102 100 215 230 410 0 525 50 711 0 Inventory details of Chicago Part # Quantity 102 0 215 75 410 0 525 0 711 220 Inventory details of Denver Part # Quantity 102 600 215 50 410 120 525 300 711 40 Inventory details of Ely Part # Quantity
  • 14. 102 210 215 160 410 30 525 80 711 50 Inventory details of Fargo Part # Quantity 102 90 215 50 410 90 525 200 711 70 Reading transaction for Purchase of 1000 quantites of part number 410 Updating the quantity of part number 410 at warehouse Baltimore Reading transaction for Sale of 120 quantites of part number 215 Updating the quantity of part number 215 at warehouse Baltimore Reading transaction for Sale of 300 quantites of part number 711 Updating the quantity of part number 711 at warehouse Atlanta ***Final (end-of-day) status for all warehouses*** Inventory details of Atlanta Part # Quantity 102 500 215 120 410 60 525 0 711 50 Inventory details of Baltimore Part # Quantity 102 100 215 110 410 1000 525 50 711 0 Inventory details of Chicago Part # Quantity 102 0
  • 15. 215 75 410 0 525 0 711 220 Inventory details of Denver Part # Quantity 102 600 215 50 410 120 525 300 711 40 Inventory details of Ely Part # Quantity 102 210 215 160 410 30 525 80 711 50 Inventory details of Fargo Part # Quantity 102 90 215 50 410 90 525 200 711 70