The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Jul 2017 |
| Last Sign in: | 364 Weeks Ago, 1 Day Ago |
| Questions Answered: | 1850 |
| Tutorials Posted: | 1850 |
Graduate in Biology and Nutrition, MBA Finance
Florida State University
Aug-2000 - Jul-2007
Ass. Relationship Manager
Penn-Florida
Mar-2009 - Feb-2016
I need help with this program. It is not working like it shows in the instructions, nor do I know how to fix it or what the psuedocode is.Â
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
Â
/**
* @author
*
*/
public class inventoryNeeded {
  /**
  * @param args
  */
  public static void main(String[] args) {
Â
    Scanner scanner = null;
    try {
      scanner = new Scanner(new File("inventory.txt"));
      File file = new File("inventoryNeeded.txt");
Â
      // if file doesnt exists, then create it
      if (!file.exists()) {
        file.createNewFile();
      }
Â
      FileWriter fw = new FileWriter(file.getAbsoluteFile());
      BufferedWriter bw = new BufferedWriter(fw);
Â
      while (scanner.hasNext()) {
        String partNumber = scanner.next();
        int quantity = scanner.nextInt();
        int sales = scanner.nextInt();
        int reqSale = scanner.nextInt();
Â
        bw.write("Part Number:" + partNumber + "\n");
        bw.write("Current Balance:" + (quantity - sales) + "\n");
        bw.write("Amount Needed:" + (reqSale - (quantity - sales))
            + "\n\n");
Â
      }
      System.out
          .println("Inventory written successfully to inventoryNeeded.txt");
      bw.close();
Â
    } catch (IOException e) {
      // TODO: handle exception
    } finally {
      if (scanner != null)
        scanner.close();
    }
  }
}
Â
inventory.txt
QA310
95
47
50
CM145
320
162
200
MS514
34
20
25
EN212
163
150
Â
160
Â
Attachments:Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m Â----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I