SlideShare a Scribd company logo
1 of 8
Download to read offline
Inventory Management System 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 500 0 75 00 220
600 50 120 300 40 210 160 30 80 500 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
Solution
driver.java
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.*;
public class driver {
public static void main(String[] args) {
try
{
File file = new File("Inventory.txt");
String line;
FileReader fileReader = new FileReader(file);
BufferedReader bufferedReader = new BufferedReader(fileReader);
line = bufferedReader.readLine();
String[] parts = line.split(" ");
int i1 = Integer.parseInt(parts[0]);
int i2 = Integer.parseInt(parts[1]);
int i3 = Integer.parseInt(parts[2]);
int i4 = Integer.parseInt(parts[3]);
int i5 = Integer.parseInt(parts[4]);
warehouse wh1 = new warehouse("Atlanta",i1,i2,i3,i4,i5);
line = bufferedReader.readLine();
parts = line.split(" ");
i1 = Integer.parseInt(parts[0]);
i2 = Integer.parseInt(parts[1]);
i3 = Integer.parseInt(parts[2]);
i4 = Integer.parseInt(parts[3]);
i5 = Integer.parseInt(parts[4]);
warehouse wh2 = new warehouse("baltimo",i1,i2,i3,i4,i5);
line = bufferedReader.readLine();
parts = line.split(" ");
i1 = Integer.parseInt(parts[0]);
i2 = Integer.parseInt(parts[1]);
i3 = Integer.parseInt(parts[2]);
i4 = Integer.parseInt(parts[3]);
i5 = Integer.parseInt(parts[4]);
warehouse wh3 = new warehouse("chicago",i1,i2,i3,i4,i5);
line = bufferedReader.readLine();
parts = line.split(" ");
i1 = Integer.parseInt(parts[0]);
i2 = Integer.parseInt(parts[1]);
i3 = Integer.parseInt(parts[2]);
i4 = Integer.parseInt(parts[3]);
i5 = Integer.parseInt(parts[4]);
warehouse wh4 = new warehouse("denver",i1,i2,i3,i4,i5);
line = bufferedReader.readLine();
parts = line.split(" ");
i1 = Integer.parseInt(parts[0]);
i2 = Integer.parseInt(parts[1]);
i3 = Integer.parseInt(parts[2]);
i4 = Integer.parseInt(parts[3]);
i5 = Integer.parseInt(parts[4]);
warehouse wh5 = new warehouse("Ely",i1,i2,i3,i4,i5);
line = bufferedReader.readLine();
parts = line.split(" ");
i1 = Integer.parseInt(parts[0]);
i2 = Integer.parseInt(parts[1]);
i3 = Integer.parseInt(parts[2]);
i4 = Integer.parseInt(parts[3]);
i5 = Integer.parseInt(parts[4]);
warehouse wh6 = new warehouse("fargo",i1,i2,i3,i4,i5);
fileReader.close();
file = new File("Transactions.txt");
fileReader = new FileReader(file);
bufferedReader = new BufferedReader(fileReader);
while(true)
{
String line1 = bufferedReader.readLine();
if(line1 == null)
{
break;
}
parts = line1.split(" ");
String ss = parts[0];
int item_num = Integer.parseInt(parts[1]);
int tmp = Integer.parseInt(parts[2]);
if(ss.equals("P"))
{
//find ware house with mininum items
int item = 0;
if(item_num == 102)
{
item = 0;
}
else if(item_num == 215)
{
item = 1;
}
else if(item_num == 410)
{
item = 2;
}
else if(item_num == 525)
{
item = 3;
}
else
{
item = 4;
}
int whouse_mith_min_items = 1;
int tmp_min = wh1.items[item];
if(wh1.items[item] < tmp_min)
{
tmp_min = wh1.items[item];
whouse_mith_min_items = 1;
}
if(wh2.items[item] < tmp_min)
{
tmp_min = wh2.items[item];
whouse_mith_min_items = 2;
}
if(wh3.items[item] < tmp_min)
{
tmp_min = wh3.items[item];
whouse_mith_min_items = 3;
}
if(wh4.items[item] < tmp_min)
{
tmp_min = wh4.items[item];
whouse_mith_min_items = 4;
}
if(wh5.items[item] < tmp_min)
{
tmp_min = wh5.items[item];
whouse_mith_min_items = 5;
}
if(wh6.items[item] < tmp_min)
{
tmp_min = wh6.items[item];
whouse_mith_min_items = 6;
}
if(whouse_mith_min_items == 1){wh1.items[item] = wh1.items[item] + tmp;}
else if(whouse_mith_min_items == 2){wh2.items[item] = wh2.items[item] + tmp;}
else if(whouse_mith_min_items == 3){wh3.items[item] = wh3.items[item] + tmp;}
else if(whouse_mith_min_items == 4){wh4.items[item] = wh4.items[item] + tmp;}
else if(whouse_mith_min_items == 5){wh5.items[item] = wh5.items[item] + tmp;}
else if(whouse_mith_min_items == 6){wh6.items[item] = wh6.items[item] + tmp;}
}
else
{
//find ware house with max items
int item = 0;
if(item_num == 102)
{
item = 0;
}
else if(item_num == 215)
{
item = 1;
}
else if(item_num == 410)
{
item = 2;
}
else if(item_num == 525)
{
item = 3;
}
else
{
item = 4;
}
int whouse_mith_min_items = 1;
int tmp_min = wh1.items[item];
if(wh1.items[item] > tmp_min)
{
tmp_min = wh1.items[item];
whouse_mith_min_items = 1;
}
if(wh2.items[item] > tmp_min)
{
tmp_min = wh2.items[item];
whouse_mith_min_items = 2;
}
if(wh3.items[item] > tmp_min)
{
tmp_min = wh3.items[item];
whouse_mith_min_items = 3;
}
if(wh4.items[item] > tmp_min)
{
tmp_min = wh4.items[item];
whouse_mith_min_items = 4;
}
if(wh5.items[item] > tmp_min)
{
tmp_min = wh5.items[item];
whouse_mith_min_items = 5;
}
if(wh6.items[item] > tmp_min)
{
tmp_min = wh6.items[item];
whouse_mith_min_items = 6;
}
if(whouse_mith_min_items == 1){wh1.items[item] = wh1.items[item] - tmp;}
else if(whouse_mith_min_items == 2){wh2.items[item] = wh2.items[item] - tmp;}
else if(whouse_mith_min_items == 3){wh3.items[item] = wh3.items[item] - tmp;}
else if(whouse_mith_min_items == 4){wh4.items[item] = wh4.items[item] - tmp;}
else if(whouse_mith_min_items == 5){wh5.items[item] = wh5.items[item] - tmp;}
else if(whouse_mith_min_items == 6){wh6.items[item] = wh6.items[item] - tmp;}
}
}
wh1.display();wh2.display();
wh3.display();wh4.display();
wh5.display();wh6.display();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
warehouse.java
public class warehouse
{
public String name ;
public int items[] = new int[5];
public warehouse(String name, int a1, int a2, int a3, int a4, int a5) {
this.name = name;
this.items[0] = a1;
this.items[1] = a2;
this.items[3] = a4;
this.items[4] = a5;
this.items[2] = a3;
}
public warehouse() {
this.name = "";
this.items[0] = 0;
this.items[1] = 0;
this.items[3] = 0;
this.items[4] = 0;
this.items[2] = 0;
}
void display()
{
System.out.println(this.name + "tt"+ this.items[0] + "t" + this.items[1] + "t" +
this.items[2] + "t"+ this.items[3]+ "t" + this.items[4]);
}
}
Inventory.txt
100 100 100 100 100
200 200 200 200 100
300 300 300 300 100
400 400 400 400 100
500 500 500 500 100
600 50 600 600 100
Transactions.txt
S 215 100
P 215 250
S 215 100
P 215 250
Output:
Atlanta 100 350 100 100 100
baltimo 200 200 200 200 100
chicago 300 300 300 300 100
denver 400 300 400 400 100
Ely 500 400 500 500 100
fargo 600 300 600 600 100

More Related Content

More from fashiongallery1

Discrete Math -Use induction to prove. The city of Inductionapolis.pdf
Discrete Math -Use induction to prove. The city of Inductionapolis.pdfDiscrete Math -Use induction to prove. The city of Inductionapolis.pdf
Discrete Math -Use induction to prove. The city of Inductionapolis.pdffashiongallery1
 
Describe polarization and why it is important to WLANs.Solution.pdf
Describe polarization and why it is important to WLANs.Solution.pdfDescribe polarization and why it is important to WLANs.Solution.pdf
Describe polarization and why it is important to WLANs.Solution.pdffashiongallery1
 
Describe the four basic elements of most communication systems.So.pdf
Describe the four basic elements of most communication systems.So.pdfDescribe the four basic elements of most communication systems.So.pdf
Describe the four basic elements of most communication systems.So.pdffashiongallery1
 
Can someone please help me figure out how to do this Required Resou.pdf
Can someone please help me figure out how to do this Required Resou.pdfCan someone please help me figure out how to do this Required Resou.pdf
Can someone please help me figure out how to do this Required Resou.pdffashiongallery1
 
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdf
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdfAssume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdf
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdffashiongallery1
 
All computer are configured for TCPIP connectivity. This exercise i.pdf
All computer are configured for TCPIP connectivity. This exercise i.pdfAll computer are configured for TCPIP connectivity. This exercise i.pdf
All computer are configured for TCPIP connectivity. This exercise i.pdffashiongallery1
 
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdf
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdf4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdf
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdffashiongallery1
 
Briefly Explain all these points belowA. Marketing channels VS cha.pdf
Briefly Explain all these points belowA. Marketing channels VS cha.pdfBriefly Explain all these points belowA. Marketing channels VS cha.pdf
Briefly Explain all these points belowA. Marketing channels VS cha.pdffashiongallery1
 
Write a class that implements the BagInterface. BagInterface should .pdf
Write a class that implements the BagInterface.  BagInterface should .pdfWrite a class that implements the BagInterface.  BagInterface should .pdf
Write a class that implements the BagInterface. BagInterface should .pdffashiongallery1
 
write an equation for the transformation of the graph of y =f(x) tra.pdf
write an equation for the transformation of the graph of y =f(x) tra.pdfwrite an equation for the transformation of the graph of y =f(x) tra.pdf
write an equation for the transformation of the graph of y =f(x) tra.pdffashiongallery1
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdffashiongallery1
 
Why are helper T-cells called helper cellsThey help pathogens i.pdf
Why are helper T-cells called helper cellsThey help pathogens i.pdfWhy are helper T-cells called helper cellsThey help pathogens i.pdf
Why are helper T-cells called helper cellsThey help pathogens i.pdffashiongallery1
 
Which of the following is NOT true of the Sons of Liberty a. New Yor.pdf
Which of the following is NOT true of the Sons of Liberty a. New Yor.pdfWhich of the following is NOT true of the Sons of Liberty a. New Yor.pdf
Which of the following is NOT true of the Sons of Liberty a. New Yor.pdffashiongallery1
 
What made the Later Roman Economy so unstable (Bennette, Medieval E.pdf
What made the Later Roman Economy so unstable (Bennette, Medieval E.pdfWhat made the Later Roman Economy so unstable (Bennette, Medieval E.pdf
What made the Later Roman Economy so unstable (Bennette, Medieval E.pdffashiongallery1
 
What data would illustrate whether these underlying problems are occ.pdf
What data would illustrate whether these underlying problems are occ.pdfWhat data would illustrate whether these underlying problems are occ.pdf
What data would illustrate whether these underlying problems are occ.pdffashiongallery1
 
1. What are distinct characteristics of baby boomers, generation X, .pdf
1. What are distinct characteristics of baby boomers, generation X, .pdf1. What are distinct characteristics of baby boomers, generation X, .pdf
1. What are distinct characteristics of baby boomers, generation X, .pdffashiongallery1
 
VERSION The cells denoted by the letter Ain the figure to.pdf
VERSION The cells denoted by the letter Ain the figure to.pdfVERSION The cells denoted by the letter Ain the figure to.pdf
VERSION The cells denoted by the letter Ain the figure to.pdffashiongallery1
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdffashiongallery1
 
The __________ is the preeminent organization for developing and pub.pdf
The __________ is the preeminent organization for developing and pub.pdfThe __________ is the preeminent organization for developing and pub.pdf
The __________ is the preeminent organization for developing and pub.pdffashiongallery1
 
The primer is required on what part of the synthesized DNA molecule.pdf
The primer is required on what part of the synthesized DNA molecule.pdfThe primer is required on what part of the synthesized DNA molecule.pdf
The primer is required on what part of the synthesized DNA molecule.pdffashiongallery1
 

More from fashiongallery1 (20)

Discrete Math -Use induction to prove. The city of Inductionapolis.pdf
Discrete Math -Use induction to prove. The city of Inductionapolis.pdfDiscrete Math -Use induction to prove. The city of Inductionapolis.pdf
Discrete Math -Use induction to prove. The city of Inductionapolis.pdf
 
Describe polarization and why it is important to WLANs.Solution.pdf
Describe polarization and why it is important to WLANs.Solution.pdfDescribe polarization and why it is important to WLANs.Solution.pdf
Describe polarization and why it is important to WLANs.Solution.pdf
 
Describe the four basic elements of most communication systems.So.pdf
Describe the four basic elements of most communication systems.So.pdfDescribe the four basic elements of most communication systems.So.pdf
Describe the four basic elements of most communication systems.So.pdf
 
Can someone please help me figure out how to do this Required Resou.pdf
Can someone please help me figure out how to do this Required Resou.pdfCan someone please help me figure out how to do this Required Resou.pdf
Can someone please help me figure out how to do this Required Resou.pdf
 
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdf
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdfAssume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdf
Assume that the Current Assets for Shine Co. as of Decebmer 31, 2011.pdf
 
All computer are configured for TCPIP connectivity. This exercise i.pdf
All computer are configured for TCPIP connectivity. This exercise i.pdfAll computer are configured for TCPIP connectivity. This exercise i.pdf
All computer are configured for TCPIP connectivity. This exercise i.pdf
 
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdf
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdf4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdf
4. At what temperature will a solution of 8.27 g CaCl2 in 45.0 g H2.pdf
 
Briefly Explain all these points belowA. Marketing channels VS cha.pdf
Briefly Explain all these points belowA. Marketing channels VS cha.pdfBriefly Explain all these points belowA. Marketing channels VS cha.pdf
Briefly Explain all these points belowA. Marketing channels VS cha.pdf
 
Write a class that implements the BagInterface. BagInterface should .pdf
Write a class that implements the BagInterface.  BagInterface should .pdfWrite a class that implements the BagInterface.  BagInterface should .pdf
Write a class that implements the BagInterface. BagInterface should .pdf
 
write an equation for the transformation of the graph of y =f(x) tra.pdf
write an equation for the transformation of the graph of y =f(x) tra.pdfwrite an equation for the transformation of the graph of y =f(x) tra.pdf
write an equation for the transformation of the graph of y =f(x) tra.pdf
 
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdfUsing c++Im also using a the ide editor called CodeLiteThe hea.pdf
Using c++Im also using a the ide editor called CodeLiteThe hea.pdf
 
Why are helper T-cells called helper cellsThey help pathogens i.pdf
Why are helper T-cells called helper cellsThey help pathogens i.pdfWhy are helper T-cells called helper cellsThey help pathogens i.pdf
Why are helper T-cells called helper cellsThey help pathogens i.pdf
 
Which of the following is NOT true of the Sons of Liberty a. New Yor.pdf
Which of the following is NOT true of the Sons of Liberty a. New Yor.pdfWhich of the following is NOT true of the Sons of Liberty a. New Yor.pdf
Which of the following is NOT true of the Sons of Liberty a. New Yor.pdf
 
What made the Later Roman Economy so unstable (Bennette, Medieval E.pdf
What made the Later Roman Economy so unstable (Bennette, Medieval E.pdfWhat made the Later Roman Economy so unstable (Bennette, Medieval E.pdf
What made the Later Roman Economy so unstable (Bennette, Medieval E.pdf
 
What data would illustrate whether these underlying problems are occ.pdf
What data would illustrate whether these underlying problems are occ.pdfWhat data would illustrate whether these underlying problems are occ.pdf
What data would illustrate whether these underlying problems are occ.pdf
 
1. What are distinct characteristics of baby boomers, generation X, .pdf
1. What are distinct characteristics of baby boomers, generation X, .pdf1. What are distinct characteristics of baby boomers, generation X, .pdf
1. What are distinct characteristics of baby boomers, generation X, .pdf
 
VERSION The cells denoted by the letter Ain the figure to.pdf
VERSION The cells denoted by the letter Ain the figure to.pdfVERSION The cells denoted by the letter Ain the figure to.pdf
VERSION The cells denoted by the letter Ain the figure to.pdf
 
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdfUsing standard libraries like stdio and sdtlib.h and using stats.h a.pdf
Using standard libraries like stdio and sdtlib.h and using stats.h a.pdf
 
The __________ is the preeminent organization for developing and pub.pdf
The __________ is the preeminent organization for developing and pub.pdfThe __________ is the preeminent organization for developing and pub.pdf
The __________ is the preeminent organization for developing and pub.pdf
 
The primer is required on what part of the synthesized DNA molecule.pdf
The primer is required on what part of the synthesized DNA molecule.pdfThe primer is required on what part of the synthesized DNA molecule.pdf
The primer is required on what part of the synthesized DNA molecule.pdf
 

Recently uploaded

DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMELOISARIVERA8
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....Ritu480198
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi RajagopalEADTU
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxLimon Prince
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文中 央社
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...Gary Wood
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfPondicherry University
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project researchCaitlinCummins3
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...EADTU
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismDabee Kamal
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024Borja Sotomayor
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptxVishal Singh
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesAmanpreetKaur157993
 

Recently uploaded (20)

DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
e-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopale-Sealing at EADTU by Kamakshi Rajagopal
e-Sealing at EADTU by Kamakshi Rajagopal
 
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptxAnalyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
Analyzing and resolving a communication crisis in Dhaka textiles LTD.pptx
 
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文會考英文
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdfFICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
FICTIONAL SALESMAN/SALESMAN SNSW 2024.pdf
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
SURVEY I created for uni project research
SURVEY I created for uni project researchSURVEY I created for uni project research
SURVEY I created for uni project research
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)ESSENTIAL of (CS/IT/IS) class 07 (Networks)
ESSENTIAL of (CS/IT/IS) class 07 (Networks)
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
The Liver & Gallbladder (Anatomy & Physiology).pptx
The Liver &  Gallbladder (Anatomy & Physiology).pptxThe Liver &  Gallbladder (Anatomy & Physiology).pptx
The Liver & Gallbladder (Anatomy & Physiology).pptx
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 

Inventory Management System objective Work with multiple objects and.pdf

  • 1. Inventory Management System 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 500 0 75 00 220 600 50 120 300 40 210 160 30 80 500 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 Solution driver.java import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.*; public class driver { public static void main(String[] args) { try { File file = new File("Inventory.txt"); String line; FileReader fileReader = new FileReader(file); BufferedReader bufferedReader = new BufferedReader(fileReader); line = bufferedReader.readLine(); String[] parts = line.split(" "); int i1 = Integer.parseInt(parts[0]); int i2 = Integer.parseInt(parts[1]);
  • 2. int i3 = Integer.parseInt(parts[2]); int i4 = Integer.parseInt(parts[3]); int i5 = Integer.parseInt(parts[4]); warehouse wh1 = new warehouse("Atlanta",i1,i2,i3,i4,i5); line = bufferedReader.readLine(); parts = line.split(" "); i1 = Integer.parseInt(parts[0]); i2 = Integer.parseInt(parts[1]); i3 = Integer.parseInt(parts[2]); i4 = Integer.parseInt(parts[3]); i5 = Integer.parseInt(parts[4]); warehouse wh2 = new warehouse("baltimo",i1,i2,i3,i4,i5); line = bufferedReader.readLine(); parts = line.split(" "); i1 = Integer.parseInt(parts[0]); i2 = Integer.parseInt(parts[1]); i3 = Integer.parseInt(parts[2]); i4 = Integer.parseInt(parts[3]); i5 = Integer.parseInt(parts[4]); warehouse wh3 = new warehouse("chicago",i1,i2,i3,i4,i5); line = bufferedReader.readLine(); parts = line.split(" "); i1 = Integer.parseInt(parts[0]); i2 = Integer.parseInt(parts[1]); i3 = Integer.parseInt(parts[2]); i4 = Integer.parseInt(parts[3]); i5 = Integer.parseInt(parts[4]); warehouse wh4 = new warehouse("denver",i1,i2,i3,i4,i5); line = bufferedReader.readLine(); parts = line.split(" "); i1 = Integer.parseInt(parts[0]); i2 = Integer.parseInt(parts[1]); i3 = Integer.parseInt(parts[2]); i4 = Integer.parseInt(parts[3]); i5 = Integer.parseInt(parts[4]); warehouse wh5 = new warehouse("Ely",i1,i2,i3,i4,i5);
  • 3. line = bufferedReader.readLine(); parts = line.split(" "); i1 = Integer.parseInt(parts[0]); i2 = Integer.parseInt(parts[1]); i3 = Integer.parseInt(parts[2]); i4 = Integer.parseInt(parts[3]); i5 = Integer.parseInt(parts[4]); warehouse wh6 = new warehouse("fargo",i1,i2,i3,i4,i5); fileReader.close(); file = new File("Transactions.txt"); fileReader = new FileReader(file); bufferedReader = new BufferedReader(fileReader); while(true) { String line1 = bufferedReader.readLine(); if(line1 == null) { break; } parts = line1.split(" "); String ss = parts[0]; int item_num = Integer.parseInt(parts[1]); int tmp = Integer.parseInt(parts[2]); if(ss.equals("P")) { //find ware house with mininum items int item = 0; if(item_num == 102) { item = 0; } else if(item_num == 215) { item = 1; }
  • 4. else if(item_num == 410) { item = 2; } else if(item_num == 525) { item = 3; } else { item = 4; } int whouse_mith_min_items = 1; int tmp_min = wh1.items[item]; if(wh1.items[item] < tmp_min) { tmp_min = wh1.items[item]; whouse_mith_min_items = 1; } if(wh2.items[item] < tmp_min) { tmp_min = wh2.items[item]; whouse_mith_min_items = 2; } if(wh3.items[item] < tmp_min) { tmp_min = wh3.items[item]; whouse_mith_min_items = 3; } if(wh4.items[item] < tmp_min) { tmp_min = wh4.items[item]; whouse_mith_min_items = 4; } if(wh5.items[item] < tmp_min) {
  • 5. tmp_min = wh5.items[item]; whouse_mith_min_items = 5; } if(wh6.items[item] < tmp_min) { tmp_min = wh6.items[item]; whouse_mith_min_items = 6; } if(whouse_mith_min_items == 1){wh1.items[item] = wh1.items[item] + tmp;} else if(whouse_mith_min_items == 2){wh2.items[item] = wh2.items[item] + tmp;} else if(whouse_mith_min_items == 3){wh3.items[item] = wh3.items[item] + tmp;} else if(whouse_mith_min_items == 4){wh4.items[item] = wh4.items[item] + tmp;} else if(whouse_mith_min_items == 5){wh5.items[item] = wh5.items[item] + tmp;} else if(whouse_mith_min_items == 6){wh6.items[item] = wh6.items[item] + tmp;} } else { //find ware house with max items int item = 0; if(item_num == 102) { item = 0; } else if(item_num == 215) { item = 1; } else if(item_num == 410) { item = 2; } else if(item_num == 525) { item = 3; } else
  • 6. { item = 4; } int whouse_mith_min_items = 1; int tmp_min = wh1.items[item]; if(wh1.items[item] > tmp_min) { tmp_min = wh1.items[item]; whouse_mith_min_items = 1; } if(wh2.items[item] > tmp_min) { tmp_min = wh2.items[item]; whouse_mith_min_items = 2; } if(wh3.items[item] > tmp_min) { tmp_min = wh3.items[item]; whouse_mith_min_items = 3; } if(wh4.items[item] > tmp_min) { tmp_min = wh4.items[item]; whouse_mith_min_items = 4; } if(wh5.items[item] > tmp_min) { tmp_min = wh5.items[item]; whouse_mith_min_items = 5; } if(wh6.items[item] > tmp_min) { tmp_min = wh6.items[item]; whouse_mith_min_items = 6; } if(whouse_mith_min_items == 1){wh1.items[item] = wh1.items[item] - tmp;}
  • 7. else if(whouse_mith_min_items == 2){wh2.items[item] = wh2.items[item] - tmp;} else if(whouse_mith_min_items == 3){wh3.items[item] = wh3.items[item] - tmp;} else if(whouse_mith_min_items == 4){wh4.items[item] = wh4.items[item] - tmp;} else if(whouse_mith_min_items == 5){wh5.items[item] = wh5.items[item] - tmp;} else if(whouse_mith_min_items == 6){wh6.items[item] = wh6.items[item] - tmp;} } } wh1.display();wh2.display(); wh3.display();wh4.display(); wh5.display();wh6.display(); } catch (IOException e) { e.printStackTrace(); } } } warehouse.java public class warehouse { public String name ; public int items[] = new int[5]; public warehouse(String name, int a1, int a2, int a3, int a4, int a5) { this.name = name; this.items[0] = a1; this.items[1] = a2; this.items[3] = a4; this.items[4] = a5; this.items[2] = a3; } public warehouse() { this.name = ""; this.items[0] = 0; this.items[1] = 0; this.items[3] = 0;
  • 8. this.items[4] = 0; this.items[2] = 0; } void display() { System.out.println(this.name + "tt"+ this.items[0] + "t" + this.items[1] + "t" + this.items[2] + "t"+ this.items[3]+ "t" + this.items[4]); } } Inventory.txt 100 100 100 100 100 200 200 200 200 100 300 300 300 300 100 400 400 400 400 100 500 500 500 500 100 600 50 600 600 100 Transactions.txt S 215 100 P 215 250 S 215 100 P 215 250 Output: Atlanta 100 350 100 100 100 baltimo 200 200 200 200 100 chicago 300 300 300 300 100 denver 400 300 400 400 100 Ely 500 400 500 500 100 fargo 600 300 600 600 100