Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In class, we wrote a program that solves quadratic equations of the form ax? + b +c= 0. Not many people are aware that a

image text in transcribed
image text in transcribed
In class, we wrote a program that solves quadratic equations of the form ax? + b +c= 0. Not many people are aware that a formula also exists to solve cubic equations of the form 2 + pr+q=0 It can be shown that any cubic equation in the general form ar + bx2 + x + d = 0 can be reduced to the form of equation (1), but we won't worry about how to do that here. Equation (1) is solvable using Cardano's formula, named after the Italian mathematician who allegedly derived it during the 1500s. The formula states that the solution is: For now, let's worry only about the real values of the quantities in (2). This means the formula will give you only one of the three roots to (1). Within your Lab2HW folder, write a program named CubicSolver.java that allows the user to enter values (potentially including decimals) for the coefficients p and q from (1). Your program should then compute and display the value of the solution according to (2). Note that although using Math. pou with an exponent of 1/3 works for computing cube roots of positive numbers, Math pow gives a result of NaN when computing the cube root of a negative number. Use Math.cbrt(x) instead: you can replace with whatever you're trying to find the cube root of. Here's an example of what your completed program might look like when you run it. Underlined parts indicate what you type in as the program is running. What is the value of p? 1 What is the value of q? 30 The solution x is -2.9999999999999742. Note that the solution given by your program may not be exact, due to the slight roundoff error that's possible when working with double values. This is totally fine

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

Students also viewed these Databases questions

Question

4. Label problematic uses of language and their remedies

Answered: 1 week ago