A stamp dealer maintains a price list that displays the country, the Scott catal
ID: 3633291 • Letter: A
Question
A stamp dealer maintains a price list that displays the country, the Scott catalog number, year of issue, description, and price:
(input)
kenya 288-92 1984 Heron Plover Thrush Gonolek Apalis $6.60
Surinam 643-54 1983 Butterflies $7.50
Seychelles 831-34 2002 WWF Frogs set of 4 $1.40
togo 1722-25 1996 Cheetah, Zebra, Antelope $5.70
The main problem I have is that if I split along space then the descriptions will be split as well where I want to keep them together
(example output)
kenya 288-92 1984 Heron Plover Thrush Gonolek Apalis $6.60
Surinam 643-54 1983 Butterflies $7.50
Seychelles 831-34 2002 WWF Frogs set of 4 $1.40
togo 1722-25 1996 Cheetah, Zebra, Antelope $5.70
TOTAL PRICE: 21.2
Explanation / Answer
#!usr/bin/perl #reads the lines from a file and formats the output and calculates a total price. Open (FILEIN, "data.txt") || die ("Cannot open file"); ttlprc= 0; while($in = ) { ($con, $catnum, $yr, $str) =split (/s/,$in, 4); $rts=reverse($str); ($prc, $desc) =split (/s/, $rts, 2); print "Country: $con "; print "Catagory Number: $catnum"; print "Year: $yr"; print "Description: $desc"; print "Price: $prc"; $ttlprc= $ttlprc + $prc ; } print "The total price is $$ttlprc";Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.