Dr. Taylor's Support Forums

You are not logged in.

#1 2006-09-20 21:08:34

taylor
Professor
From: Milwaukee, WI
Registered: 2004-08-30
Posts: 266
PM  Website

Questions about Lab 1 and code documentation

Someone asked the following via email:

For the Lab, what exactly did you want included with the report.  I got a little confused reading the webpage about documenting the source code.

I have added comments to the code that we talked about earlier this quarter.  I've included the code below and linked it from the schedule page.  Hopefully this example along with the description here will help make it clear.  If not please add follow-up questions here.

Code:

/*
 * Course: SE-1010
 * Section: 2
 * Term: Fall 2006
 * Author: Dr. Wu
 * Assignment: Lab 0
 * Date: 09/15/2006
 */
package lab0;

import javax.swing.*;
import java.text.*;

/**
 * This class contains one method that prompts the user for the
 * radius of a circle.  It calculates the area and circumference
 * for a circle with the entered radius and displays the answer
 * to the console.
 *
 * @version 1.0 09/15/2006
 * @author Dr. Wu
 */
public class Ch2Circle3 {

    /**
     * The main method that implements the functionality for the
     * Ch2Circle3 class.
     *
     * @author Dr. Wu
     * @param args Ignored
     */
    public static void main(String[] args) {
        
        final double PI = 3.14159;
        
        // Identifier creation
        String radiusStr;
        double radius;
        double area;
        double circ;
        java.text.DecimalFormat df 

        // Object creation
        df = new java.text.DecimalFormat("0.000");
        
        // Popup a window prompting the user to enter the radius
        radiusStr = JOptionPane.showInputDialog(null, "Enter radius:");

        // Converts the value of the radius from the String
        //  representation (raduisStr) to a double (radius).
        radius = Double.parseDouble(radiusStr);
        
        area = PI * radius * radius;
        circ = 2.0 * PI * radius;
        
        // Display results in the console window
        System.out.println("");
        System.out.println("Given radius: " + radius);
        System.out.println("Area: " + df.format(area));
        System.out.println("Circumference: " + df.format(circ));;
    }

}

Offline

 

#2 2006-09-21 15:08:15

Xodial
Member
From: Milwaukee, WI
Registered: 2006-09-06
Posts: 17
PM

Re: Questions about Lab 1 and code documentation

What about the sample output?  Did you want any particular format?  Ex. "Your yearly income is: $7565.00", or did you want the inputs too with all of the messages associated with the inputs?  Or did you simply want the output value:  7565.00?  Or just the output line as in my example above?

-Daniel Stone

Last edited by Xodial (2006-09-21 15:08:37)


Daniel Stone

Offline

 

#3 2006-09-22 06:49:07

taylor
Professor
From: Milwaukee, WI
Registered: 2004-08-30
Posts: 266
PM  Website

Re: Questions about Lab 1 and code documentation

Your sample output should be the entire contents of the console window for one running of your program.

Offline

 

Board footer

This website is not owned or managed by the Milwaukee School of Engineering.

© 2001-2007 Dr. Christopher C. Taylor, et. al., • Office: L-343 • Phone: 277-7339 • npǝ˙ǝosɯ@ɹolʎɐʇ