Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROGRAM Quadratic_equation1 ! This program the roots of the quadratic equation using the ! quadratic formula ! ! Constant: epsilon ! Variables: a,b,c,discriminant, root1, root2

PROGRAM Quadratic_equation1

! This program the roots of the quadratic equation using the

! quadratic formula

!

! Constant: epsilon

! Variables: a,b,c,discriminant, root1, root2

! discriminant=b**2 - 4.0*a*c

! Input: Coefficients of the quadratic equation a,c and c

! Output: a,b,c, epsilon, discriminant, root 1, root 2

!

IMPLICIT NONE

! Constant declaration

REAL, PARAMETER ::epsilon=1E-6

!Variables declaration

REAL::a.b.c. discriminant, sqrt_discriminant,root1,root 2

!Read in the input

PRINT*, "Enter the three coefficient a,b, and c:"

READ*,a,b,c

! Test if a equals zero. if yes, exit the program

IF (a.LT.epsilon)THEN

PRINT*,"The value of a is zero. Execution terminated"

STOP

END IF

discriminant=b**2-4*a*c

PRINT*, "The coefficient are:", a,b,c

PRINT*, "The value of the discriminant is", discriminant

! Check if the discriminant is negative.

! If it is, print message and stop the program

IF (discriminant .LT.0.0)THEN

PRINT*, "Discriminant is negative. The are no REAL roots"

STOP

END IF

!Check if the discriminant is zero

!If it is, calculate and print the single real root

!Otherwise calculate and print the two real roots

IF abs(discriminant)

root1=b**2/2.0*a

PRINT*,"The root is", root 1

ELSE

sqrt_discriminant=SQRT(discriminant)

root1=(-b + sqrt_dsicriminant)/(2.0*a)

root2=(-b - sqrt_discriminant)/(2.0*a)

PRINT*,"The roots are",root1,root2

END IF

END PROGRAM Quadratic_equation1

Question:

image text in transcribed

2. Modify the Fortran program in Example 4.10 to also calculate the complex roots when the discriminant is negative. The complex roots are given by X= -b-Di 2a where D is the discriminant and 2. Modify the Fortran program in Example 4.10 to also calculate the complex roots when the discriminant is negative. The complex roots are given by X= -b-Di 2a where D is the discriminant and

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

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions

Question

=+4 Develop and deliver the CCT program.

Answered: 1 week ago

Question

=+5 Evaluate whether the CCT program was effective.

Answered: 1 week ago

Question

=+Identify the type of global assignment for which CCT is needed.

Answered: 1 week ago