Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a java program and you can only use the java.util.Scanner; java.util.io.*; java.util.ArrayList; You run a restaurant where you allow customers to put items on

Write a java program and you can only use the java.util.Scanner; java.util.io.*; java.util.ArrayList; You run a restaurant where you allow customers to put items on their "tab". When a customer buys something, you write down the name of the customer, the price of the item, and the name of the item on a line in a log file. The customer name, price, and item name are separated by a # sign. At the end of the month, you want to be able to compute the total for each customer, and the total sales for each item.

We will model this using a class called Entry that contains two fields: a name, and a price. We will use two separate ArrayLists of type Entry in the class CustomerLog: one list will contain an Entry for each customer, and the other an Entry for each item. As we process the log file, when we read each line (hint: use split () ), we will update the appropriate entry in each of the two lists. Or, if the line includes a new customer or a new item, we will add an Entry to the appropriate list(s).

At the end, we will write the customer results to a file (one customer per line), and the item results to a file (one item per line). The program should take three filename (the log file which is provided, and the two result files) as command line parameters.

Run the program by typing the following command:

java CustomerLog log.txt CustLog.txt ItemLog.txt

IF the log.txt file contains the following contents:

john smith#2.59#espresso

cindy jones#3.18#turkey sandwich

john smith#6.70#turkey sandwich

abby james#5.18#espresso

john smith#18.40#soup

john smith#9.99#chesseburger

cindy jones#4.44#soup

THEN the result file CustLog.txt should contains:

john smith 37.68

cindy jones 7.62

abby james 5.18

AND the result file ItemLog.txt should contains:

espresso 7.77

turkey sandwich 9.88

soup 22.84

chesseburger 9.99

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_2

Step: 3

blur-text-image_3

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

Microsoft Visual Basic 2017 For Windows Web And Database Applications

Authors: Corinne Hoisington

1st Edition

1337102113, 978-1337102117

More Books

Students also viewed these Databases questions

Question

Explain the role of an Investment bankers/ IPO process ?

Answered: 1 week ago