Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

For this assignment, include in your code the definitions of getInteger and getF

ID: 3821231 • Letter: F

Question

For this assignment, include in your code the definitions of getInteger and getFloat from lecture. As discussed in lecture, when entering the numbers, the user (i.e., you!) should enter one number per line: otherwise, Haskell will likely have difficulty parsing them correctly. In the examples that follow, I've used colors to distinguish Haskell output (blue), user-generated input (orange), and the values returned by actions (black). 1. Write a Haskell program stats:: Io (Float, Float) that (i) prompts the user to enter three numbers, (ii) reads in three Floats, and then (iii) returns a pair containing the mean (i.e., numerical average) and median (i.e., middle value) of those three numbers. Reminder: maximum and minimum are useful built-in functions. For example, your program should have the following behavior: *Main > stats Please enter three numbers: 10 25 12 (15.666667, 12.0)

Explanation / Answer

Haskell Code to Find the Average of Three Float numbers is :

averageThree :: Float -> Float -> Float -> Float

averageThree a b c = (a + (b + c))/3.0

isAbove :: Float -> Float -> Int

isAbove a avg

| a > avg = 1

| otherwise = 0

numAbove :: Float -> Float -> Float -> Int

numAbove a b c = (isAbove a avg) + (isAbove b avg) + (isAbove c avg)

  where

   avg = averageThree a b c

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote