The pseudocode needed only No Java needed Students will des
The pseudocode needed only
No Java needed
----------------------------------------
Students will design the logic for an application and submit a partially completed Java program.
The BMC Parts Company needs a program that will read the inventory.txt file and create an inventory report based on the data in the file. The inventory.txt file contains the part number, opening balance, number of items sold, and the minimum stock required. The output file, inventoryNeeded.txt, will contain the part number, current balance and the amount that is necessary to bring the inventory to the minimum level.
In this assignment, students will design the logic for the program that reads the input file and creates the output file. Files provided include inventory.txt and the partially completed program inventoryNeeded.java. The program file provided includes the necessary variable declarations and input and output file statements. You need to write the part of the program that reads the input file, calculates the current balance and amount required to bring the inventory to the minimum level. Then output the part number, current balance and the amount needed to the output file.
In this assignment, students will submit both the .java and the .class files for the completed program along with the output file created from the program execution, and the pseudocode. The files will be submitted by the posted due date using the appropriate dropbox.
The pseudocode must be submitted as a Microsoft Word compatible file. Examples of Word compatible documents are those with a .doc, .docx, or .rtf file extension. If there is a question about the format, consult with your instructor before submitting your assignment.
inventory.txt file contains:
QA310
95
47
50
CM145
320
162
200
MS514
34
20
25
EN212
163
150
160
Output file – inventoryNeeded.txt should look like this
inventoryNeeded.txt - Notepad File Edit Format View Help Part Number: QA310 Current Balance: 48 Amount Needed: 2 Part Number: CM145 Current Balance: 158 Amount Needed: 42 Part Number: MS514 Current Balance: 14 Amount Needed: 11 Part Number EN212 Current Balance: 13 Amount Needed: 147Solution
// Inventory.java
import java.io.*;
import java.util.*;
import java.io.PrintWriter;
public class Inventory
{
public static void main(String[] args)
{
File inputFile = new File(\"inventory.txt\");
// Check if file exists
if (!inputFile.exists())
{
System.out.println(\"File does not exist!\");
System.exit(1);
}
String part_Number;
int opening_Balance, items_Sold, minimum_stock_required;
BufferedWriter output = null;
try(BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream(inputFile))))
{
File file = new File(\"inventoryNeeded.txt\");
output = new BufferedWriter(new FileWriter(file));
String str;
part_Number = bf.readLine();
while (true)
{
str = bf.readLine();
opening_Balance = Integer.parseInt(str);
str = bf.readLine();
items_Sold = Integer.parseInt(str);
str = bf.readLine();
minimum_stock_required = Integer.parseInt(str);
output.write(\"\ \ Part Number: \" + part_Number + \"\ \");
output.write(\"Current balance: \" + (opening_Balance- items_Sold) + \"\ \");
output.write(\"Amount Needed: \" + (minimum_stock_required-(opening_Balance- items_Sold)));
if((part_Number = bf.readLine()) == null)
break;
}
// output file
output.close();
}
catch (FileNotFoundException exception)
{
System.out.println(\"File not found.\");
exception.printStackTrace();
}
catch (IOException exception)
{
System.out.println(\"IO error.\");
exception.printStackTrace();
}
}
}
/*
inventory.txt
QA310
95
47
50
CM145
320
162
200
MS514
34
20
25
EN212
163
150
160
inventoryNeeded.txt
Part Number: QA310
Current balance: 48
Amount Needed: 2
Part Number: CM145
Current balance: 158
Amount Needed: 42
Part Number: MS514
Current balance: 14
Amount Needed: 11
Part Number: EN212
Current balance: 13
Amount Needed: 147
*/


