[erlang-questions] Help Please
Lucky Khoza
mrkhoza@REDACTED
Fri Nov 9 11:20:35 CET 2012
Thanks to all for inputs and i will try it out, and therefore i will ask
you to comment as well.
On Fri, Nov 9, 2012 at 12:05 PM, Jesper Louis Andersen <
jesper.louis.andersen@REDACTED> wrote:
> Lucky,
>
> the purpose of an exercise is to train you in working with a new
> programming language. You need to sit down and make an attempt at solving
> the problem yourself. Therein lies the wisdom and learning. I suggest that
> you start out by reading through the problem description and then write
> down code for the problem at hand. If you have a concrete question as to
> how a certain part of Erlang works, I am sure you will get a lot of helpful
> answers, but no, we won't solve your homework for you.
>
> In fact, why pry the delight of having solved it yourself?
>
> Some hints to get you started though:
>
> A. You have a .csv file. It should definitely be read in (see the 'file'
> module in the documentation of erlang at erlang.org).
> B. You must find an internal representation in memory of the file in
> question.
> C. You must manipulate said representation until it matches the desired
> result.
> D. You must format and print out the result. Perhaps the io and io_lib
> modules can help (beware, they are slightly different in nature.
> Understanding the difference is important).
>
> Jesper Louis Andersen
> Erlang Solutions Ltd., Copenhagen
>
>
>
> On Nov 9, 2012, at 8:31 AM, Lucky Khoza <mrkhoza@REDACTED> wrote:
>
> > Hi,
> >
> > May you kindly help with the exercise below using Erlang [I am new
> Erlang Development]:
> >
> > Introduction
> >
> > Meet Mr. and Mrs. Hollingberry. Recently retired, Mr. Hollingberry has
> decided to move to sunny South Africa and open up a small local convenience
> store to keep him and Mrs. Hollingberry out of mischief.
> >
> > Alas, it turned out not be such a laid-back job as he had hoped...
> >
> > The Problem
> >
> > One of their current problems is printing price tags on their fresh
> produce. Every morning, as soon as the various produce have been delivered,
> Mrs. Hollingberry enters it into a program her nephew had written.
> >
> > The result is a comma-seperated file that includes, among other fields,
> the cost price (in cents) and delivery date of each product.
> >
> > The Task
> >
> > Your job is to write a program that reads the csv file and then creates
> a new file that will be used to print out the price tags.
> >
> > The Input File
> >
> > An example csv file is in this directory (produce.csv). We use the
> following fields:
> >
> > • Supplier ID. > All suppliers are equal, but some are more equal
> than others.
> >
> > • Product code. > This tells us what kind of produce we're dealing
> with.
> >
> > • Description. > We can print part of this on the price tag.
> >
> > • Delivery date. > YYYY-MM-DD. We use this to calculate the sell-by
> date.
> >
> > • Cost price. > In cents. We use this to calculate the selling price.
> >
> > • Unit count. > We need to print a price tag for each item delivered.
> >
> > The Output File
> >
> > The price file has 3 fields on each line: the selling price, the sell-by
> date and a product description.
> >
> > The price file is in fixed-width format, because the label printer has
> limited space (50 characters) for each price tag. Each line in the price
> file will cause one price tag to be printed.
> >
> > The selling price takes up 9 characters. One currency symbol (R) and 8
> digits where Rands and cents are seperated by a period: R99999.99
> >
> > Mr Hollingberry says we shouldn't worry about larger amounts. If he ever
> sells something for a 100 grand he will have to retire again, and he can't
> take that kind of stress again.
> >
> > The sell-by date, just like the delivery date in the input file, is in
> YYYY/MM/DD format (10 characters).
> >
> > The remaining 31 characters is used for the product description.
> >
> > A typical line in the price file will look like this:
> >
> > R 19.922012/05/26Apples 1kg Green. They are very
> >
> > The Business Rules
> >
> > You have to calculate the selling price and the sell-by date. Luckily we
> can use the description just as it is in the csv file. Well, the first 31
> characters of it anyway.
> >
> > Markup Rules
> >
> > • The markup for apples is 40%.
> > • The markup for bananas is 35%.
> > • The markup for berries is 55%.
> > • The markup for anything else 50%.
> > Premium Produce (tm)
> >
> > Some suppliers are dedicated Premium Produce (tm) suppliers. The
> customer has to believe that they are buying something better than usual.
> We do this by making the packaging look nice, and by increasing the price.
> The suppliers already took care of the nice packaging, you now have to make
> it expensive. Anything supplied by a Premium Produce (tm) supplier gets an
> additional 10% markup, and then the price is rounded up to the nearest
> Rand. For example, if a product costs R25.11 after the extra 10% markup has
> been applied, you need to round it up to R26. The Premium Produce suppliers
> currently are: * Promise Mashangu (Supplier ID 219) * Karel Visser
> (Supplier ID 204)
> >
> > Sell-by Dates
> >
> > • Apples have to be sold 2 weeks after the date of delivery.
> > • Bananas have to be sold 5 days after the date of delivery.
> > • All other types of fruit has to be sold 1 week after the date of
> delivery.
> > Supplier Troubles
> >
> > One the suppliers, Susan Windler (Supplier ID 32), has been known to
> deliver fruit that is not quite as fresh as that of the other suppliers.
> Mr. Hollingberry has decided to handle this quietly, by ensuring that the
> sell-by date for anything delivered by Susan is always 3 days earlier than
> normal. Come to think of it, Togetherness Tshabalala (Supplier ID 101),
> also needs to be on this list.
> >
> > Product Codes
> >
> > • Fruit has product codes ranging from 1000 to 1999.
> > • Apples specifically have product codes ranging from 1100 to 1199.
> > • Bananas have product codes ranging from 1200 to 1299.
> > • Berries have product codes ranging from 1300 to 1399.
> >
> >
> > Kindest Regards
> > Lucky KHoza
> >
> >
> > _______________________________________________
> > erlang-questions mailing list
> > erlang-questions@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121109/2613e746/attachment.htm>
More information about the erlang-questions
mailing list