CIMP7A java documentation is modeled after the standard JavaDoc - JavaDoc documentation standard is covered in CS4B.
All programs you write must meet our documentation standard. The standard is critical for the following reasons:
Standards
For example, Submit file name TripleInteger.java
Program with correct documentation
/**
* Read an integer from standard input, integer read is guaranteed
* to be between -2^20 to 2^20, this is important because program
* doesn't have to worry about overflow, a Java int uses 32bits,
20 bit input so we are safe. After reading the integer
just output the the number read and its tripled valued.
* Sample Run...
25
The number 25 tripled is 75
* @input integer n from Standard Input System.in
* @logic take input n multiply by 3, in output statement its n*3
* @output: "The number n tripled is n*3\n" Where n is integer just red
* @author jstudent0
*/
public class TripleInteger {
/**
* input integer n triple it, does all the work
@param args
*/
public static void main( String[] args )
{
int n; //integer to be read
//use default standard input stream create formatted input stream
java.util.Scanner input = new java.util.Scanner( System.in );
n = input.nextInt( );
System.out.println( "The number " + n + " tripled is " + n*3 ); //output
//println will terminated the line with a newline characters
} //end main
} //end class TripleInteger
Submit CertificateDeposit.java (Heavily commented program with most code removed)
/**
* Given an initial $1000.00 investment, Program allows a use to enter
* an annual interest rate, and the term of a CD in months, it then
* outputs the future value of the $1000.00 CD at end of term.
*
* @input read annual interest rate and term of CD in months (all double) from stdin
* @logic future value = ($1000.00)*(1+AnnualRate/1200)^months
* since we are compounding monthly, we divide annual rate by 12, to go from
* a percentage to a floating number we divide by 100. e.g., 1% = .01
* so we have Fv = PV * ( 1 + AnnualRate/(12*100)) ^ months; where 1 is 100%
* using printf to print 2 digits past decimal point for initial value
* future value, and annual rate, its printf("%.2f",100); --> 100.00
* @output the value of a $1000.00 CD at end of term
*
* @author tdedonno2
*/
public class CertificateDeposit {
/**
* main method does all work of program
*/
/*
* not we only use ** before class names, methods and global variables
* this program has way too many comments, but beginners should always
* over comment than under comment
*
* Data Table
* constant double PV = 1000.0 Present (aka initial) Value
* double rate annual interest 10% is stored as 10 not .01
* double term number of months for investment
* double fv Future value calculated
*/
/* declare constants
use keyword final before double, to create double constant */
//declare other variables all double
//annual rate and term in months for investment
//create formatted input stream
//Prompt use for annual interest rate & then months
; //enter rate
//Prompt user for term
/*
* using formatter System.out.printf
* where "%.2f" will print 2 digits pass decimal point,
* it is recommended you test this printf first
* System.out.printf( "An initial investment of $%.2f at rate %.2f%%\n",
* 1000.0, 2.566 );
*
* Given a 12 month 1.2 rate, The output string you need to create is...
"An initial investment of $1000.00 after 12 months at annual rate of 1.20% is $1012.07\n"
*/
/*
complete next portion of output use use %.0f term and %.2f%%
for annual rate, note in printf %% will output % */
/**
calculate the final value using
PV * Math.pow( (1.0+rate/1200.0), term );
note we have 12 months / year so we divide by 12
but an interestRate of 10% is the double 10/100
so we need to divide by 12*100 aka 1200
Equation:
http://home.ubalt.edu/ntsbarsh/business-stat/otherapplets/compoundcal.htm
*/
//output the final string using %.2f\n new line terminated
} //end main
} //end clss CertificateDeposit