0% found this document useful (0 votes)
41 views

Example 1. State The Problem: Input

This document outlines the design of a program to solve quadratic equations. It will: 1) Prompt the user for the coefficients a, b, and c of the equation ax^2 + bx + c = 0. 2) Calculate the discriminant and determine if there are two distinct real roots, two repeated real roots, or no real roots. 3) Output the real roots of the equation or a message about there being no real roots.

Uploaded by

nimcan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Example 1. State The Problem: Input

This document outlines the design of a program to solve quadratic equations. It will: 1) Prompt the user for the coefficients a, b, and c of the equation ax^2 + bx + c = 0. 2) Calculate the discriminant and determine if there are two distinct real roots, two repeated real roots, or no real roots. 3) Output the real roots of the equation or a message about there being no real roots.

Uploaded by

nimcan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Example 1.

State the problem


Design and write a program to solve for the real The problem statement for this example is very
roots of a quadratic equation. simple. We want to write a program that will solve
for the real roots of a quadratic equation, whether
they are distinct real roots, or repeated real roots.

1 2

2. Define input and outputs 3. Design algorithm


Input: This task can be broken down into three major
sections, whose functions are input, processing,
The inputs required by this program are
and output:
coefficients , , and of the quadratic equation
Read the input data
+ + =0
Calculate the roots
Output: Write out the roots

The output from the program will be the real roots We will now break each of the above major
of the quadratic equation, whether they are distinct sections into smaller, more detailed pieces.
real roots, or repeated real roots.
3 4

4. Pseudocode 4. Pseudocode
Prompt the user for the coefficients a, b, and c. IF discriminant < 0 THEN
Read a, b, and c Write message that equation has no real roots.
Echo the input coefficients ELSE IF discriminant > 0 THEN
discriminant ← b**2 - 4. * a * c x1 ← (-b + sqrt(discriminant)) / (2. * a )
x2 ← (-b - sqrt(discriminant)) / (2. * a )
Write message that equation has two distinct real
roots.
Write out the two roots

5 6
4. Pseudocode
ELSE
x1 ←-b / (2. * a)
Write message that equation has two identical
real roots.
Write out the repeated root.
END IF

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy