Question

In: Computer Science

Warehouse Inventories Objective: Work with multiple objects and review reading data files. Description: A wholesale distributor...

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 C# 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 C# 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.

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

driver.java

import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

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

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 +
      "\t\t" +
      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


Related Solutions

PLEASE DO IN C# Warehouse Inventories Objective: Work with multiple objects and review reading data files....
PLEASE DO IN C# 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)...
Basic Unix Commands Objective: The objective of this lab is to work with files of UNIX...
Basic Unix Commands Objective: The objective of this lab is to work with files of UNIX file system. Procedure: 1. OpenyourUnixshellandtrythesecommands: Ø Create a new file and add some text in it vcat > filename Ø View a file vcat /etc/passwd vmore /etc/passwd vmore filename Ø Copy file, making file2 vcp file1 file2 Ø Move/rename file1 as file2 vmv file1 file2 Ø Delete file1 as file2 vrm file //Deletefile //Double-checkfirst vrm -i file Ø Counts the lines, words, characters in...
The objective of this homework assignment is to demonstrate proficiency with reading files, and using string...
The objective of this homework assignment is to demonstrate proficiency with reading files, and using string methods to slice strings, working with dictionaries and using-step wise development to complete your program. Python is an excellent tool for reading text files and parsing (i.e. filtering) the data. Your assignment is to write a Python program in four steps that reads a Linux authentication log file, identifies the user names used in failed password attempts and counts the times each user name...
Quantum Logistics, Inc., a wholesale distributor, is considering the construction of a new warehouse to serve...
Quantum Logistics, Inc., a wholesale distributor, is considering the construction of a new warehouse to serve the southeastern geographic region near the Alabama–Georgia border. There are three cities being considered. After site visits and a budget analysis, the expected income and costs associated with locating in each of the cities have been determined. The life of the warehouse is expected to be 12 years and MARR is 15%/year. City Initial Cost Net Annual Income Lagrange $1,260,000 $480,000 Auburn $1,000,000 $410,000...
Objective Work with strings Work with files Work with formatted output This program will display a...
Objective Work with strings Work with files Work with formatted output This program will display a very basic handling of transactions for a checking account. The program will read in a data file with all the past transactions. Use FileUtil.selectOpenFile or input() to get a file name from the user. The format of the file will be very basic, just a date (as a string in the format of MM/DD), a single letter which indicates the type of transaction (‘B’...
Quantum Logistics, Inc., a wholesale distributor, is considering constructing a new warehouse to serve the southeastern...
Quantum Logistics, Inc., a wholesale distributor, is considering constructing a new warehouse to serve the southeastern geographic region near the South Carolina-Georgia border. There are three cities being considered. After site visits and a budget analysis, the expected income and costs associated with locating in each of the cities have been determined. The life of the warehouse is expected to be 12 years, and MARR is 15 percent / year. Based on an internal rate of return analysis, which city...
PYTHON...... Working with lists, functions, and files Objective: Work with lists Work with lists in functions...
PYTHON...... Working with lists, functions, and files Objective: Work with lists Work with lists in functions Work with files Assignment: Part 1: Write a program to create a text file which contains a sequence of test scores. Ask for scores until the user enters an empty value. This will require you to have the scores until the user enters -1. After the scores have been entered, ask the user to enter a file name. If the user doesn’t not enter...
Find a healthcare organization’s description of how it utilizes big data. Review their description of this...
Find a healthcare organization’s description of how it utilizes big data. Review their description of this usage: For what purpose? Who performs the actual analysis? Can you tell whether the analysis is done internally or externally? Are the results current? Are the results useful in some way, and is that usefulness described?
The following data relate to the operations of Shilow Company, a wholesale distributor of consumer goods:...
The following data relate to the operations of Shilow Company, a wholesale distributor of consumer goods: Current assets as of March 31: Cash $ 9,000 Accounts receivable $ 26,000 Inventory $ 48,600 Building and equipment, net $ 109,200 Accounts payable $ 29,175 Common stock $ 150,000 Retained earnings $ 13,625 The gross margin is 25% of sales. Actual and budgeted sales data: March (actual) $ 65,000 April $ 81,000 May $ 86,000 June $ 111,000 July $ 62,000 Sales are...
The following data relate to the operations of Shilow Company, a wholesale distributor of consumer goods:...
The following data relate to the operations of Shilow Company, a wholesale distributor of consumer goods:      Current assets as of March 31:      Cash $ 8,700      Accounts receivable $ 24,800      Inventory $ 46,800   Building and equipment, net $ 116,400   Accounts payable $ 28,050   Capital stock $ 150,000   Retained earnings $ 18,650    a. The gross margin is 25% of sales. b. Actual and budgeted sales data:      March (actual) $62,000   April $78,000   May $83,000   June $108,000   July $59,000    c....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT