Section 2e

Step Three


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Systematic and Structured Programming

Step Three - Identifying and Locating the Methods

Once again, step two was not difficult. In fact, between writing steps one and two, you probably still don't have a whole 20 minutes invested in this process. That's just one of the benefits here.

Once again (again), you will also find that step three is just an expansion of step two, although you will be taking some new actions here. Mostly however, you will just be filling in areas that are guided by what you wrote in your previous steps.

If you are working through this with the web page, you must create a new class named in your Project_1/p1_package structure. This class will be named QuadClass_StepThree. You must then copy the contents of the main method in QuadClass_StepTwo into the main method of your QuadClass_StepThree. At this point, you want to save what was stored as step two for your future review.

Now, you must work your way through the program from top to bottom following the iterative refinement process. This time, you will be identifying the need for, and the use of, methods in your program, but because you are not required to develop your own methods, you will not be creating any new methods in this activity. You will only use those developed by others.

Start here (iteratively)

Initialize the program

   // initialize program

// initialize variables

// show title
   // initialize program

// initialize variables

// show title
// method: System.out.println

Get the coefficients from the user

   // get coefficients from user

// get coefficient A

// get coefficient B

// get coefficient C
   // get coefficients from user

// get coefficient A
// method: JOptionPane.showInputDialog, Double.parseDouble

// get coefficient B
// method: JOptionPane.showInputDialog, Double.parseDouble

// get coefficient C
// method: JOptionPane.showInputDialog, Double.parseDouble

Process the quadratic roots

   // Process the quadratic roots

// calculate the discriminant
// calculate the square root of the discriminant

// calculate the denominator

// calculate roots

// calculate root one // calculate root two
   // Process the quadratic roots

// calculate the discriminant

// calculate the square root of the discriminant
// method: Math.sqrt

// calculate the denominator

// calculate roots

// calculate root one // calculate root two
   package p1_package;

import javax.swing.JOptionPane;
import java.lang.Math

Display the roots

   // display roots

// display user input

// display root one

// display root two
   // display roots

// display user input
// method: System.out.println

// display root one
// method: System.out.println

// display root two
// method: System.out.println

End the program

   // end program

// display program end
   // end program

// display program end

// method: System.out.println

Completing Step Three

Some more notes:


To see the step three process in action, watch this video; then develop your step three code with or without the video as needed in your own IDE.