Menu

[solved]-Assignment Requires Create One Java File Assignmentjava Read Data Two Text Files Process D Q39011784

This assignment requires you to create only one Java file,Assignment.java, to read data from two text files,process these data to generate and print information, and also saveupdated data in a new text file

  1. The following two input text files contain data for the aboveprogram to read and process. They must be downloaded and saved in afolder named ‘Ass_Data‘, which you create by handbut must be at the same level in the disc as where Assignment.javais located. For example, if the program is saved inC:ProjAssignment, these two files should be saved inC:ProjhomeworkAss_Data. (CANNOT UPLOAD FILES TO CHEGG, JUSTCOME UP WITH RANDOM ORDERS AND CUSTOMERS)
  2. Customers.txt contains 91 customerIDs, whichare sorted and each is a 5-char string on its own line. Customersof this file are companies
  3. Orders.txt contains 2155 lines of customerorder data. In this file, each line represents one line item ofcertain customer order that contains 21 tab-separated data fieldsdefined below, where EmployeeID represents the ID of one of ouremployees who handles the order, Freight means the shipping andhandling fee, and Discount values like 0.05 or 0.2 means 5% or 20%discount. All date values in this file can be treated and processedas strings.
    • CustomerID
    • CompanyName
    • ContactName
    • ContactTitle
    • Address
    • City
    • Region
    • PostalCode
    • Country
    • Phone
    • Fax
    • OrderID
    • OrderDate
    • RequiredDate
    • ShippedDate
    • EmployeeID
    • Freight
    • ProductID
    • UnitPrice
    • Quantity
    • Discount
  4. Because normally an order consists of more than one line item,you will find several lines together in Orders.txt make one order.For instance, the very first three lines belong to order 10248 ofcustomer VINET, and line 4 and 5 together define order 10249 ofcustomer TOMSP.
  5. You will implement Assignment.java program,which acquires two input file names, Orders,txt and Customers.txt,that are entered at command line (i.e., in args[] of main()) andreads both files completely as shown in the screenshotbelow.  ON. Administrator: Command Prompt C: Proj Assignment >javac Assignment 7. java two file names are entered to run the C:Pro
  6. In case of missing file name(s) or incorrect file name(s) areentered, the program must handle the errors or exceptions with areadable message and stop its execution. The next screenshotprovides three sample tests and their messages for your reference.You may implement them in your own way using try-catch or if-else,etc., but displaying the same error messages as shown in thescreenshot is recommended.  
  7. OR. Administrator: Command Prompt C:Proj VAssignment >java Assignment --------begin of Assignment ---------- No file names a
  8. The first console screenshot above is a requirement, meaningyour Assignment.java must execute to process the data files anddisplay information as shown in the screenshot, including outputlines between “begin of Assignment” and “end of Assignment”.
  9. Your program, Assignment.java, must first display two lines toindicate the total lines read from the input files. See the firstscreenshot above.
  10. Your program, Assignment.java, must answer five queries definedbelow and display their answer in the form as shown in the firstscreenshot.
  11. Q1: There are 2155 order lines in theOrders.txt, but these orders belong to only a small number ofcustomers (or companies). How many customers (or companies) can befound from Orders.txt? Do not count the same customer twice. Theanswer should be 89 customers.

    Q2: How many different orders can be found fromOrders.txt? Do not count the same order twice. The answer should be830 orders.

    Q3: Customers.txt contains 91 customers intotal. Compared to Orders.txt, where only 89 customers are found.That means, there should be two customers not appeared inOrders.txt because they never place any orders. Who are thesecustomers? The answer should be FISSA and PARIS.

    Q4: Every line item’s total amount iscalculated by ‘unit price * quantity * (1 – discount)’.Accumulating the total of line items of the same order gives thegrand total amount of that order. If we rank orders in terms oftheir grand total amount, then, which order is the largest order?What’s its order ID and who is the customer?

    Q5: Similar to Q4, except for the smallestorder.

  12. Before end, your program, Assignment.java, will write data to anew text file, which is created at run-time, not by hand, and mustbe named ‘SIM.txt‘ in the same location as theother two input text files. In case the file already exists, yourprogram will replace or overwrite its contents in each execution.This file contains a subset ofOrders.txt, which must be orders of customers in countries ofSpain, Italy, Mexico, and Canada, i.e., SIMC, and, if an order lineitem’s discount is originally zero, it is updated to be3% in SIMC.txt, and if the original discount is20% or higher, it is decreased by 1% and saved inSIMC.txt. Lines that satisfy these conditions will be copied,modified, and saved with only 8 fields, which are CustomerID,Country, OrderID, OrderDate,  
    ProductID, UnitPrice, Quantity, and Discount. All data fields mustbe tab-separated.
  13. As seen in the first screenshot, the previous writing fileoperation needs to be concluded with a message to indicate how manylines are copied from Orders.txt and how many of them whosediscount value is updated. For your reference, a correct sample ofthe output file is provided here SIM.txt. No needto upload your output file for grading.

ON. Administrator: Command Prompt C: Proj Assignment >javac Assignment 7. java two file names are entered to run the C:Proj Assignment >java Assignment 7 Orders. txt Customers. txt) program ——–begin of Assignment ———- File ../Ass _Data/Orders.txt is read successfully with 2155 lines File ../Ass _Data/Customers.txt is read successfully with 91 lines (Q1) Total customers in orders file = 89 (02) Total orders in orders file = 830 (03) 2 customers with no orders = FISSA PARIS (Q4) Largest order = $16387.5, which is order 10865 of customer QUICK (05) Smallest order = $12.5, which is order 10782 of customer CACTU File ../Ass Data/SIMC.txt is created (254 lines) but only 200 lines are updated ——–end of Assignment ——- C:2510 Assignment > OR. Administrator: Command Prompt C:Proj VAssignment >java Assignment ——–begin of Assignment ———- No file names are entered ….Did you forget to enter file names at command line? Please re-run this program. ——–end of Assignment. ———- C:Proj VAssignment >java Assignment ABC.txt Customers.txt I——–begin of Assignment ———- Incorrect file name … No file of ../Ass_Data/ABC.txt can be found. Please check if such a file exists and re-run this program. .. … Reading ABC.txt failed ——-end of Assignment C:Proj Assignment >java Assignment ABC.txt XYZ.txt ——–begin of Assignment ———- Incorrect file names …. No file of …/Ass _Data/ABC. txt can be found. Please check if such a file exists and re-run this program. . . . . . Reading ABC.txt failed ———end of Assignment ———- C:ProjAssignment> Show transcribed image text ON. Administrator: Command Prompt C: Proj Assignment >javac Assignment 7. java two file names are entered to run the C:Proj Assignment >java Assignment 7 Orders. txt Customers. txt) program ——–begin of Assignment ———- File ../Ass _Data/Orders.txt is read successfully with 2155 lines File ../Ass _Data/Customers.txt is read successfully with 91 lines (Q1) Total customers in orders file = 89 (02) Total orders in orders file = 830 (03) 2 customers with no orders = FISSA PARIS (Q4) Largest order = $16387.5, which is order 10865 of customer QUICK (05) Smallest order = $12.5, which is order 10782 of customer CACTU File ../Ass Data/SIMC.txt is created (254 lines) but only 200 lines are updated ——–end of Assignment ——- C:2510 Assignment >
OR. Administrator: Command Prompt C:Proj VAssignment >java Assignment ——–begin of Assignment ———- No file names are entered ….Did you forget to enter file names at command line? Please re-run this program. ——–end of Assignment. ———- C:Proj VAssignment >java Assignment ABC.txt Customers.txt I——–begin of Assignment ———- Incorrect file name … No file of ../Ass_Data/ABC.txt can be found. Please check if such a file exists and re-run this program. .. … Reading ABC.txt failed ——-end of Assignment C:Proj Assignment >java Assignment ABC.txt XYZ.txt ——–begin of Assignment ———- Incorrect file names …. No file of …/Ass _Data/ABC. txt can be found. Please check if such a file exists and re-run this program. . . . . . Reading ABC.txt failed ———end of Assignment ———- C:ProjAssignment>

Expert Answer


Answer to This assignment requires you to create only one Java file, Assignment.java, to read data from two text files, process th… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *