Question: import java.util.Scanner;import java.io . FileInputStream; import java.io . IOException; 4 public class RetrieveInfo { static final String INVENTORY _ FILE = Inventory.txt ; static

import java.util.Scanner;import java.io.FileInputStream;
import java.io.IOException;4 public class RetrieveInfo {
static final String INVENTORY_FILE = "Inventory.txt";
static final String PROMPT = "Enter a SKU to search for: ";
static final String WARNING ="
WARNING: Duplicate SKUs found";public static void main(String[] args) throws IOException {
boolean found = false;int cntFound =0;
int numSKUs =0;
String partSKU, partName, manufacturer, country;
String outString;
Scanner scnr = new Scanner(System.in);
// Get the PartSKU to Search from the User
System.out.println(PROMPT);
String search = scnr.nextLine().strip().toUpperCase();
System.out.println("");
/* TO DO: Insert your commands for loading the INVENTORY FILE hereand a Scanner Object to hold it called "inFile" that we'll use to load data */
/* TO DO: Loop through the Scanner inFile using a while loop to loadeach successive line into the appropriate variables that we pre-defined:
partSKU, partName, manufacturer, country.If the SKU was found at least once, print "SKU FOUND:"+ partSKU on the first item found and then print to the console the found information for each item found in the array as partName -- manufacturer (country)
Use counters to track how many objects you've found and how many you've searched in the file.
See the variables that we've provided and see if those can help you do that!/*TO DO: Do your housekeeping and close the fileStream that you opened, we've finished using it */
/*/* TO DO: Display standard completion messages for the different cases:
TO DO: If more than one match were found, print the WARNING message to the console */
If no matches were found:
"No SKUs were found for:"+ search
If at least 1 record was found
(where # is the variable you're using for the # of records found):
#+" record(s) found."
Also, print to the console how many records you searched
(where # is the variable you're using for the total records):#+" record(s) searched."
import java.util.Scanner;import java.io .

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!