Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Calculating Sales Create a perl script named calcSales that reads an input file specifying sales figures and outputs a tabulation of these figures. Each line

Calculating Sales Create a perl script named calcSales that reads an input file specifying sales figures and outputs a tabulation of these figures. Each line of the input file will be a string of the form name+ or name+sales. The name will not contain any '+' characters. The sales, if present, will be an integer or floating point number (i.e., there may or may not be a decimal point). The name of the input file will be specified on the command line. So, execution of this program might look like this: perl calcSales.pl salesFigures.txt The output will consist of a list of names and sales figures, sorted alphabetically by name, that remain after the following processing: 1. Multiple sales entries for the same name are added. 2. An entry that does not contain a sales value (e.g.: "Matt Evett+") will erase any entries so far encountered for that name in the data file (but further encounters having a value will "restart" the accumulation for that name with the new value. You should use a hash to accomplish this. Use the names as keys into the hash, and store the current sales accumulation with that key. Here is a sample input: John+19 Michael+12 Chunske+10 John+ Michael+3 John+1.52 Bobby+22 Michael+11 And here is a sample output. Note that the accumulated values are aligned: NAME SALES Bobby 23.80 John 4.52 Matt Evett 10.00 Michael 26.00

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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions