Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OMIT 2. Develop a Haskell function prodSqSmall that takes three Double arguments and returns the product of the squares of the two smaller numbers. For

OMIT

2. Develop a Haskell function prodSqSmall that takes three Double arguments and returns the product of the squares of the two smaller numbers.

For example, prodSqSmall 2.0 4.0 3.0 yields 36.0.

3. Develop a Haskell function xor that takes two Booleans and returns the exclusive-or of the two values. An exclusive-or operation returns True when exactly one of its arguments is True and returns Falseotherwise.

4. Develop a Haskell Boolean function implies that takes two Booleans p and q and returns the Boolean result p \Rightarrow q (i.e. logical implication). That is, if p is True and q is False, then the result is False; otherwise, the result is True.

Note: This function is sometimes called nand.

OMIT

OMIT

7. Develop a Haskell function ccArea that takes the diameters of two concentric circles (i.e. circles with the same center point) as Double values and returns the area of the space between the circles. That is, compute the area of the larger circle minus the area of the smaller circle. (Hint: Haskell has a builtin constant pi.)

For example, ccArea 2.0 4.0 yields 9.42477796076938 on the authors Mac.

OMIT

9. Develop a Haskell function addTax that takes two Double values such that addTax c p returns c with a sales tax of p percent added. For example, addTax 2.0 9.0 returns 2.18.

Also develop a function subTax that is the inverse of addTax. That is, subTax (addTax c p) p yields c. For example, subTax 2.18 9.0 yields 2.0.

OMIT

11.A day on the calendar (usual Gregorian calendar used in the USA) can be represented as a tuple with three Int values (month,day,year) where the year is a positive integer, 1 <= month <= 12, and 1 <= day <= days_in_month. Here days_in_month is the number of days in the the given month (i.e. 28, 29, 30, or 31) for the given year.

Develop a Boolean Haskell function validDay d that takes a date tuple d and returns True if and only if d represents a valid date.

For example, validDay (8,20,2018) and validDay(2,29,2016} yield True and validDay (2,29,2017) and validDay(0,0,0) yield False.

Note: The Gregorian calendar was introduced by Pope Gregory of the Roman Catholic Church in October 1582. It replaced the Julian calendar system, which had been instituted in the Roman Empire by Julius Caesar in 46 BC. The goal of the change was to align the calendar year with the astronomical year.

Some countries adopted the Gregorian calendar at that time. Other countries adopted it later. Some countries may never have adopted it officially.

However, the Gregorian calendar system became the common calendar used worldwide for most civil matters. The proleptic Gregorian calendar extends the calendar backward in time from 1582. The year 1 BC becomes year 0, 2 BC becomes year -1, etc. The proleptic Gregorian calendar underlies the ISO 8601 standard used for dates and times in software systems.

12. Develop a Haskell function roman that takes an Int) in the range from 0 to 3999 (inclusive) and returns the corresponding Roman numeral as a string (using capital letters). The function should halt with an appropriate error messages if the argument is below or above the range. Roman numbers use the following symbols and are combined by addition or subtraction of symbols.

I 1
V 5
X 10
L 50
C 100
D 500
M 1000

For the purposes of this exercise, we represent the Roman numeral for 0 as the empty string. The Roman numbers for integers 1-20 are I, II, III, IV, V, VI, VII, VIII, IX, X, XI, XII, XIII, XIV, XV, XVI, XVII, XVII, XIX, and XX. Integers 40, 90, 400, and 900 are XL, XC, CD, and CM.

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions