Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in c++ stored data 1111 Dish Washer 20 250.50 550.50 2222 Micro Wave 75 150.00 4

ID: 3693013 • Letter: I

Question

in c++ stored data 1111 Dish Washer 20 250.50 550.50 2222 Micro Wave 75 150.00 400.00 3333 Cooking Range 50 450.00 850.00 4444 Circular Saw 150 45.00 125.00 infix data A+B-C; (A+B)*C; (A+B)*(C-D); A+((B+C)*(E-F)-G)/(H-I); A+B*(C+D)-E/F*G+H; Task II: Write a program to keep track of a hardware store inventory in order to become familiar with the vector type and discover how to sort records using recursive functions. Write a program to keep track of a hardware store inventory. The store sells various items. For each item in the store, the following information is kept: item ID, item name, number of pieces ordered, number of pieces currently in the store, number of pieces sold, manufacturers price for the item, and the stores selling price. At the end of each week, the store manager would like to see a report in the following form: The total inventory is the total selling value of all of the items currently in the store. The total number of items is the sum of the number of pieces of all of the items in the store. Your program must be menu driven, giving the user various choices, such as checking whether an item is in the store, selling an item, and printing the report. After inputting the data, sort it according to the items names. Also, after an item is sold, update the appropriate counts. Initially, the number of pieces (of an item) in the store is the same as the number of pieces ordered, and the number of pieces of an item sold is zero. Input to the program is a le consisting of data in the following form: itemID itemName pOrdered manufPrice sellingPrice Use seven parallel vectors to store the information. The program must contain at least the following functions: one to input data into the vectors, one to display the menu, one to sell an item, and one to print the report for the manager.

Explanation / Answer

import java.util.*; 02 import java.io.FileNotFoundException; 03 import java.io.FileReader; 04 import java.io.PrintWriter; 05 06 public class HardwareInventory 07 { 08     public static void main (String[] args) throws FileNotFoundException 09     { 10         //Instantiation of vector elements. 11         VectoritemID = new Vector(); 12         VectoritemName = new Vector(); 13         VectorpOrdered = new Vector(); 14         VectorpInStore = new Vector(); 15         VectorpSold = new Vector(); 16         VectormanufPrice = new Vector(); 17         VectorsellingPrice = new Vector(); 18 19          Scanner inFile = new Scanner(new FileReader("data.i")); 20          PrintWriter printWriter = new PrintWriter("data.r"); 21     } 22       23     public static void inputData(Scanner inFile,VectoritemID,VectoritemName,VectorpOrdered, 24             VectorpInStore,VectorpSold,VectormanufPrice,VectorsellingPrice, Integer Integer) 25     { 26         int id,inStore; 27         int sold = 0; 28         String name; 29         Double price, salePrice; 30           31         while(inFile.hasNext()) 32         { 33             id = inFile.nextInt(); 34             name = inFile.nextLine(); 35             inStore = inFile.nextInt(); 36             price = inFile.nextDouble(); 37             salePrice = inFile.nextDouble(); 38               39             itemID.addElement(id); 40             itemName.addElement(name); 41             pOrdered.addElement(inStore);   42             pInStore.addElement(inStore);   43             pSold.addElement(sold); 44             manufPrice.addElement(price); 45             sellingPrice.addElement(salePrice); 46           47         } 48           49           50               51           52           53     } 54       55       56 }