Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need to create this Java program but I'm stuck invoice_example.txt order.txt * order.txt Invoice.java X 10 import java.io.PrintWriter; O2 import java.util.Scanner; 03 import java.io.FileInputStream; #4

Need to create this Java program but I'm stuck

image text in transcribed

invoice_example.txt

image text in transcribed

order.txt

image text in transcribed

* order.txt Invoice.java X 10 import java.io.PrintWriter; O2 import java.util.Scanner; 03 import java.io.FileInputStream; #4 import java.io.FileOutputStream; 5 import java.io.IOException; 6 70 /** 8 * This programs must: 9 9 10 1. Read from order.txt and write to invoice.txt. 11 2. Write a header to the output file. 12 3. For each line of the input file: 13 a. Read the quantity, price, and description. 14 b. Compute the extension (quantity * price) 15 c. Format and write these values to the output file using printf. 16 d. Keep track of the running total. 17 4. After all lines have been processed, write the total to the file using printt. 18 19 Refer to AddLineNumbers.java and Reviews.java for pieces needed to develop this program. 20 21 * Do not assume that the input file has a certain number of lines. Your program must 22 * continue reading until the end of the input file is reached. 23 24 Before starting, look at invoice_example.txt to see how the invoice.txt file you are going 25 * to create must be formatted. 26 27 * The first time you run this program, invoice.txt is not going to appear automatically 28 * in Eclipse. To see the file, right-click on the FileIO project and choose Refresh. 29 */ 30 31 public class Invoice 320 public static void main(String[] args) throws IOException { 33 // YOU MUST USE THESE EXACT FILENAMES! Do not change them or your program 34 // will not run correctly for grading. 9235 String inputFileName = "order.txt"; 36 String outputFileName = "invoice.txt"; 37 38 // Insert your logic here 39 40 } 41} 42 LA36 Reviews.java *Invoice.java invoice_example.txt X 1 The following lines show what your invoice.txt file should look like. 2 3 Qty Description Price Ext 4 5 Backpack $ 19.99 $ 99.95 5 10 Paper $0.99 $ 9.90 6 3 Pens $ 1.49 $ 4.47 7 2 Pencils $ 1.19 $ 2.38 9 Total: $ 116.70 10 order.txt X 1$ 19.99 Backpack 2 10 0.99 Paper 33 1.49 Pen 42 1.19 Pencil

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions