CS 1400 Lab #8: Algorithm Design


Objectives:

After completing this lab you should be familiar with the process used to analyze simple computing problems and be able to design algorithms to solve them. You will be expected to use this process on every assignment in this course, from now on.

Study Material

In order to do this exercise, you should go back through this week's set of slides on Program Design. Study the example shown in the slides thoroughly. Be sure that you understand the steps required to design and develop a computer program.

Make a copy of the Algorithm Design Worksheet located here. Use this worksheet to develop a solution to the Farmer John problem here. This is not a time to be lazy! Good programmers spend a significant part of their time making sure that they understand the problem that they are trying to solve, and doing the hard design work before they start to code. Do not try to write the program for this problem at this point.

The Pseudo-code Programming Process

The Pseudo-code Programming Process was developed by Steve McConnell, and is explained in detail in his book "Code Complete" by Microsoft Press.

Before proceeding, you should have worked through the solution to the Farmer John problem using the Algorithm Design Worksheet. In this exercise, you will begin the process of writing the program for solving this problem. Carefully follow these steps:

  1. Create a folder for lab #8.
  2. Start Visual Studio and start a new Console project.
  3. From your algorithm design worksheet copy the line by line description that you wrote for solving this problem. We call this line by line description Pseudo-code. It should accurately reflect the steps that your program will take, expressed in short English phrases. Note that it is insufficient to say things like "Calculate the area of the circle". Your descriptions should explain how each calculation is done.

    Now paste this pseudo-code into your program as shown below:

    // File Prologue
    // CS 1400-X01
    // Mary Coder
    // Lab #8
    // May 2013
    // I did not copy any code except that provided by the instructor
    //---------------------------------------------------------------
     
    using System;
    using static System.Console;  
    namespace lab08
    {
       class Program
       {
          static void Main()
          {
             // paste your pseudo-code here
     
             ReadKey(true);
          }
       }
    }

  4. Place slashes // in front of each line of code, so that they appear as comments
  5. Do not try to write any other code at this point. Save your project.

Questions

When you submit this lab, add a comment on Canvas when you upoad your file, that contains the answers to the following questions. The answers to these questions can be found in the study material included in this lab.

Question #1: When is the proper time to write pseudo-code?
    (a) as you think about the way that your program should work
    (b) as you test your program
    (c) when your program is complete and you know that it works
    (d) when you package your application and submit it to Canvas

Question #2: When is the proper time to develop test cases for your program?
    (a) as you think about the way that your program should work
    (b) as you test your program
    (c) when your program is complete and you know that it works
    (d) when you package your application and submit it to Canvas

File(s) to Submit:

Place a copy of the source code file containing your pseudo-code in a zip file and name the zip file lab_08_your-initials_V1.0.zip. For example, I would name my file lab_08_RKD_V1.0.zip. Submit this assignment as lab #8 on Canvas. Please do not include any other files in your submission.

Questions

When you submit this lab, add a comment on Canvas when you upoad your file, that contains the answers to the following questions. The answers to these questions can be found in the study material included in this lab.

Grading Guidelines

Description Points possible

Assignment has been properly submitted to Canvas.

2

Source code file contains pseudo-code that accurately describes the problem to be solved.

3

The answers to the questions in this lab have been included as comments on your submission, and they are correct.

2
Total 7