Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Develop the Haskell function formatDollars :: Price -> String that takes a Price in cents and formats a string in dollars and cents. For

1. Develop the Haskell function

 formatDollars :: Price -> String

that takes a Price in cents and formats a string in dollars and cents. For example, formatDollars 1307 returns the string 13.07. (Note the 0 in 07.)

1B: Using formatDollars above, develop the Haskell function

 formatLine :: (Name, Price) -> String 

that takes an item and formats a line of the receipt for that item. For example,

 formatLine ("Claw hammer",788)

yields the string:

 "Claw hammer...................7.88 "

This string has length lineWidth not including the newline character. The space between the items name and cost is filled using '.' characters.

1C:Using the formatLine function above, develop the Haskell function

 formatLines :: CartPrices -> String

that takes a list of priced items and formats a string with a line for each item. (In general, the resulting string will consist of several lines, each ending with a newline.)

*** These are questions that are building upon each other and i am needing help. ***

Thank you to whoever helps me on this, I really appreciate it.

This is the pricelist we use for the last part:

 database :: PriceList database = [ (1848, "Vanilla yogurt cups (4)", 188), (1620, "Ground turkey (1 lb)", 316), (1492, "Corn flakes cereal", 299), (1773, "Black tea bags (100)", 307), (2525, "Athletic socks (6)", 825), (9595, "Claw hammer", 788), (1945, "32-in TV", 13949), (1066, "Zero sugar cola (12)", 334), (2018, "Haskell programming book", 4495) ]

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

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago