Question: To do this, begin your session with import scala.math._ 1. Problem Write a function that given the coefficients of a quadratic polynomial ax2+bx+c, returns the

To do this, begin your session with

import scala.math._

To do this, begin your session with import scala.math._ 1. Problem Write

1. Problem Write a function that given the coefficients of a quadratic polynomial ax2+bx+c, returns the real roots: Option [(Double, solve (2, solve (1, solve (1, -2, -4) 0, 1) 0, -1) Double) resO: res1 Option [ (Double, Double)J None res2: Option [ (Double, Double)Some ( (1.0,-1.0)) > . Some ((2.0,-1.0)) Notes: Our version of solve returns an option containing a tuple. Options and tuples are discussed here: Options. Maps and Tuples. When there are two real roots, as in the first example, solve returns a Some object containing the roots as a pair of doubles Whem ihcre are no noot, as in hte second cuampl, solve retuns None How would you modify solve to return complex roots

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!