Section 8b

Step One, Reviewed


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Systematic and Structured Programming, Part 2

Step One - Simple Action Statements (Reviewed)

Once More, for Extra Support

This page is almost identical to the Step One page in Chapter 2. There are a few changes but Step One does not change whether you create your own functions or not. You may want to scan through this chapter and move on to the next one. However, it never hurts to review something this important to watch for things you might have missed in your first pass through it.

The Problem to Be Solved

The beginning of the process is to identify the problem and try to elicit all the important actions that your program is required to do. Here is an example program specification:

  1. The program solves for the roots of a quadratic equation

  2. For the following equation, it prompts the user for, and acquires, the x2 coefficient (A), the x coefficient (B), and the constant coefficient (C), for the following equation:

  3. Ax2 + Bx + C = 0

  4. Finally, the program provides the roots of the equation to the user as a displayed output The first step is to identify the main parts of the program and write them in as comments. This program will only require a few simple statements. The following statements are provided with explanations, and then the code itself is provided.

Initialize the program

Get the coefficients from the user

Process the quadratic roots

Display the roots

End the program

The main function code for step one would look like the following:

    

public static void main( String[] args )
{
// initialize program

// get coefficients from user

// process quadratic roots

// display roots

// end program
}

As you may notice, and as you have up to now experienced, it doesn't take more than a few minutes to write this, and while it may seem trivial, it is very important because you now have a feeling for how the program will flow. Even more importantly, you have broken the program down into smaller, more manageable problems.

Some notes:


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