Your Perfect Assignment is Just a Click Away
We Write Custom Academic Papers

100% Original, Plagiarism Free, Customized to your instructions!

glass
pen
clip
papers
heaphones

CSC-2591 Java Programming Standards

CSC-2591 Java Programming Standards

CSC-2591 Java Programming Standards

The following standards are to be followed in writing Java programs. They are important enough to be part of the grading criteria for all programs. Any constructs not covered in this standard are to be implemented in a consistent and readable fashion.

PURPOSE

The purpose of these rules are (1) to introduce you to a representative set of coding standards that are typical in professional programming and (2) to help you develop good style as a habit, something you will find necessary to successfully complete large programs. There is no doubt that you can write Java programs to solve the small problems in this course without attention to style. But, you must keep in mind that you are building professional skills, not merely finding the answers to problems handed out as exercises.

Assignment Submission

Classes

Code Style

Comments

Constants

Declarations

File Names And Java Compiler

Homework Template Submission

Output

Program Design

Program Header

The “this” C onstruct

The toString M ethod

ASSIGNMENT SUBMISSION

Please name your document submission based on the assignment instructions

Please see each individual JAVA problem for naming requirements.

The deliverables that are to be uploaded to the assignment are:

1) This completed document. (PLEASE DO NOT INCLUDE IN THE ZIPPED FILE).

2) All Java source code in a zipped file.

Make sure you:

Attach your completed template in Microsoft Word format (.doc or docx) or a PDF format. If the word or pdf file that is submitted does not open in myLearning so I may grade it, the assignment will receive a zero.

Make sure all screen shots are complete and legible. See directions on assignment.

GO TO TOP OF DOCUMENT

CODE STYLE

Use doubles for all floating point calculations.

Use int for all integer calculations

Use integer division only when you are willing to lose accuracy.

Each constant and variable declaration should be on a separate line that includes a comment above it that explains what each is. For example:

// voltage in the circuit

double volts = 12.3;

// amperage in the circuit

int amps = 1;

// name of the circuit

String circuitName = “”;

Variables should be initialized where they are declared. You shall always initialize variables.

Line Length – Avoid lines longer than 80 characters, since they’re not handled well by many terminals and tools.

Include line numbers in all programs.

Be descriptive in your prompts to the user.

When you notice you are repeating blocks of code, look for a better approach.

Alignment and indentation of lines of Java statements add much to the readability of programs. The following guidelines are general so that you may develop your own programming style:

· Use indentation and blank lines as you see fit to increase the readability of your programs.

· Use whitespace (blank lines and spaces on lines) liberally!

· Use parentheses liberally!!

· Before you submit your program use the Eclipse Format function to format your final submission.

The body of a control structure, such as an if, a switch, a while, a do, or a for statement, should be indented. The following examples illustrate the only formatting style that is to be used in this class. Each level of indenting is 4 spaces. (All of the below examples should have 4 spaces for indentation, but not all browsers display it correctly.)

if statement

if (expression)

{

statements

}

if-else statement

if (expression)

{

statements

}

else

{

statements

}

switch statement

switch (selector variable)

{

case case-1-value:

case 1 statements;

break;

case case-2-value:

case 2 statements;

break;

case case-n-value:

case n statements;

break;

default:

default statements;

break;

}

while statement

while (expression)

{

statements

}

do-while statement

do

{

statements

}

while (expression);

for statement

for (initialization; condition; increment)

{

statements

}

GO TO TOP OF DOCUMENT

CLASSES
All classes should be implemented in separate files.

Any potential for stale data should be avoided. When designing a class you should limit the fields that you have in the class to those that are only necessary for input to the computations.

All data that is calculated should not be return through fields in the class but should be returned through methods that return the results of the calculation.

For example, if you have a class Rectangle that has fields length and width, there should not be a field area; a method such as claculateArea() should return the area of the rectangle.

Getters and setters should be included for all instance variables.

Setters should use data validation checking to insure that all data passed to the class is valid.

Multiple constructors should be implemented including the default constructor.

The default constructor must be included in every class.

When overriding a class make sure the first line before the override is:

@Override

For example:

@Override

public String toString() {

String str;

return str; }

GO TO TOP OF DOCUMENT

COMMENTS

Please include comments throughout your program where applicable.

Have your comments above the statements they are commenting; not to the side of them. It makes for better readability.

Each constant and variable declaration should be on a separate line that includes a comment above it that explains what each is. For example:

// voltage in the circuit

double volts = 12.3;

Before you submit your program use the Eclipse Format function to format your final submission. This will make a better fit for your comments on the page.

Each method MUST be identified by a Javadoc comment describing its purpose, parameter(s), and the method(s) it calls. See Chapter 02.

The format to be used is as follows:

/**

* calculates and returns the charge for shipping cargo

* between two planets.

*

* @param distance distance in miles between two planets

* @param weight weight in pounds of item being shipped

* @return A double representing the cost to ship the item in space

*/

public double findSpaceCost(long distance, float weight)

{

// implement here

}

GO TO TOP OF DOCUMENT

CONSTANTS

Use named constants to make your program more readable and maintainable.

Constant name should be in upper case and use underscores between words.

Use the modifier final for constants.

Do not use literals in your calculations; use named constants.

Use 5 digits of accuracy for all constants such as PI.

Constant values used in your program will be given in final declarations. Constant identifiers should always appear in all-capital letters; underscore characters delimit multiple words. For example:

Examples:

// Units kg/m3

final double DENSITY_OF_LEAD = 11340.1;

// PI to 5 places

final double PI = 3.14159;

// signals word continued on next line

final char HYPHEN = ‘-‘;

// names can be 20 characters

final int NAME_LENGTH = 20;

GO TO TOP OF DOCUMENT

DECLARATIONS

Use mnemonic names for all identifiers. Be descriptive of what the variable represents when you name variables. (Use speed instead of s or spd). Minimize the use of abbreviations in naming variables.

Use camel casing for all variable names. Variable identifiers should be in all lower-case letters, except for capital letters used to delimit multiple words in a variable identifier. For example, shippingRates, idEntry, numberOfItems, and minScoreRequired.

When dealing with floating point numbers, use doubles and when dealing with integers, use type int.

One declaration per line is required. In other words,

// indentation level

int level = 3;

// size of table

int size = 4;

Should be used instead of:

int level = 3, size = 4;

Use separate variables for everything you are to compute. Do not perform calculations in output statements. Associate all calculations with variable names.

Classes should begin with a capital letter, and multiple words should be indicated by additional capital letters (for example, Date, VehicleNumber, SoftwareEngineer, BankAccount).

Methods should begin with a lowercase letter, and have any multiple words indicated by capital letters (for example, isValidNumber(), area(), setWidth(), etc). Note: Constructors are methods which cannot follow this convention, because their names must exactly match the class name.

Each identifier declaration (including method declarations page 79 of the text) must be accompanied by a comment that explains its use.

Avoid declaring globally-visible variables. Globally-visible constants, enumerated types, classes, and file names are acceptable, but do not use global variables unless the project assignment specifically tells you to do so.

GO TO TOP OF DOCUMENT

FILE NAMES AND JAVA COMPILER

In this course each Java file name should clearly represent what it is and each should have the “.java” suffix. Files names must match the class name. For example, Project 1 should be Project1.java. We will be using the Eclipse IDE exclusively for all program development.

GO TO TOP OF DOCUMENT

INPUT DATA VALIDATION

Once chapter 3 has been completed, all input data should be checked for validity. Some data should fall in a specific range, for example if you were to input a person’s age, it would be realistic to check for values between 0 and some upper limit, perhaps 125 years. If you were inputting length, you would expect a value greater than or equal to zero. In some cases you will have data such as temperature with negative values.

If you get data that falls outside your expected ranges, notify the program user and loop until the user inputs data within the acceptable range. In general, a do-while statement tends to be an efficient structure to perform these checks.

PROGRAM HEADER

At the beginning of each Java class there should be a PROGRAM HEADER using a

JavaDoc block (Chapter 02 of the text) that contains the following:

1. The assignment name, your name email and telephone number, the date built, the file name and the project name.

2. A brief description (at least 2 lines) of the program that describes the method or algorithm used to obtain the solution, the major data structures (if any) in the program, and other general comments including extra features.

3. The Completed Honor Code.

The format to be used is as follows:

/**

//***********************************************************************

‘Project: Assignment #

‘Programmer: FULL NAME

‘Company Info: EMAIL

‘Date: DD MM YYYY

‘Description: Problem Number #.

‘ LINE 1 AT LEAST 3 LINES OF PROGRAM DESCRIPTION

‘ LINE 2 AT LEAST 3 LINES OF PROGRAM DESCRIPTION

‘ LINE 3 AT LEAST 3 LINES OF PROGRAM DESCRIPTION

‘ ————————————————————————–

‘ HONOR CODE:

‘ I pledge that this program represents my own program code, I have received

‘ help from no one and I have given help to no one.

‘ OR

‘ I received help from NAME OR NO ONE in designing and debugging my program.

‘ I given help to NAME OR NO ONE in designing and debugging my program.

‘—————————————————————————–

‘ LINE LENGTH – AVOID LINES LONGER THAN 80 CHARACTERS

‘ SCALE BELOW IS TO CALIBRATE SCREENSHOTS

‘ DO NOT HAVE YOUR CODE OR SCREENSHOT EXTEND BEYOND THE SCALE

0……..1………2………3………4………5………6………7………8

12345678901234567890123456789012345678901234567890123456789012345678901234567890

*/

This you tube video is excellent and describes exactly how and why to use JAVADOC COMMENTS.

Play Now

GO TO TOP OF DOCUMENT

PROGRAM DESIGN

Use stepwise refinement. The programming assignments given are ones that can be solved in a step-by-step manner. The method of solution used in your program should exhibit this kind of structure.

Modularize your program. When a problem solution readily splits into distinct tasks, your program should handle each task in a separate function and in a straightforward manner.

Make your program efficient. Your algorithm should be direct and not unnecessarily complicated. Proper use of data structures will often simplify an algorithm.

Use parameters appropriately. All variables used in a method should either be declared as parameters or be declared locally within the method.

GO TO TOP OF DOCUMENT

OUTPUT

All input values should be echoed in a labeled readable manner unless otherwise indicated. This means when data is input via the keyboard it should be output to the console in one place, just before the results of any computations. This assures that the person who input the data will see what she input.

For all work use printf or String.format for formatting of all output. Do NOT use DecimalFormat.

(After completing Chapter 02)

The program output should be readable and clearly labeled.

Headings should be used when outputting data in tabular format.

Use 2 decimal places with all numeric output unless specifically indicated otherwise. (After completing Chapter 02)

Use separate variables for everything you are to compute. Do NOT perform calculations in output statements.

Use correct spelling throughout your program.

Space and format your output correctly.

GO TO TOP OF DOCUMENT

HOMEWORK TEMPLATE SUBMISSION

Please name Homework Template Submission XXX_ Assignment0N where XXX are your initials and N is the assignment number.

Where your assignment asks for:

“PLACE SCREEN SHOT OF PROGRAM CODE and CONSOLE OUTPUT HERE.”

Please note that I used the windows snipping tool for the screen shot, had the appropriate comments in the program, had the program number as it was in the assignment in the program, highlighted the program name and project comment in yellow using the snipping tool. A yellow highlight is also used with the output and the date and time the program was run is shown. In addition, all code from the program meets all standards in this document, is numbered, visible and legible. Use a white background to show screen shots of programs, as seen below. Your console output may have a black background. Screen shots of programs with a black background are quite difficult to read and will receive a grade of zero for the problem. Your console output may have a black background.

Line Length – Avoid lines longer than 80 characters, since they’re not handled well by many terminals and tools.

THIS IS WHAT IS EXPECTED FROM THE SCREEN SHOT:

If you are using JOptionPane Show Screen shots of all messages and I/O for all cases, for example:

GO TO TOP OF DOCUMENT

The toString Method

The toString method should be implemented for all classes in Homework 03 and forward. See Chapter 06 videos.

Use Stringbuilder in developing toString Methods for Homework 05.

GO TO TOP OF DOCUMENT

The “this” Construct

The “this” construct should be exclusively used in setting instance variables for all classes in Homework 05. See Chapter 08.

GO TO TOP OF DOCUMENT

Finally, of course, your program should produce correct results!

Some of this material was paraphrased from a Purdue University document.

V2017.01 © ER Whalen 2017

assignment 05/JAVA_TEMPLATE.txt
/** //*********************************************************************** ‘Project: Assignment # ‘Programmer: FULL NAME ‘Company Info: EMAIL ‘Date: DD MM YYYY ‘Description: Problem Number #. ‘ ‘ LINE 1 AT LEAST 3 LINES OF PROGRAM DESCRIPTION ‘ LINE 2 AT LEAST 3 LINES OF PROGRAM DESCRIPTION ‘ LINE 3 AT LEAST 3 LINES OF PROGRAM DESCRIPTION ‘ ‘ ————————————————————————– ‘ HONOR CODE: ‘ I pledge that this program represents my own program code, I have received ‘ help from no one and I have given help to no one. ‘ ‘ OR ‘ ‘ I received help from NAME OR NO ONE in designing and debugging my program. ‘ I given help to NAME OR NO ONE in designing and debugging my program. ‘—————————————————————————– ‘ ‘ LINE LENGTH – AVOID LINES LONGER THAN 80 CHARACTERS ‘ SCALE BELOW IS TO CALIBRATE SCREENSHOTS ‘ DO NOT HAVE YOUR CODE OR SCREENSHOT EXTEND BEYOND THE SCALE 0……..1………2………3………4………5………6………7………8 12345678901234567890123456789012345678901234567890123456789012345678901234567890 */

assignment 05/T_Assignment05.docx
Homework 05 Chapters 08, 09 and 10

Name: Isabella Hawkins

CSC 2591

COMPLETE THE HONOR CODE BELOW

‘———————————————————————————-

‘ HONOR CODE:

‘ I pledge that this program represents my own program code, I have received

‘ help from no one and I have given help to no one.

‘———————————————————————————–

Assignment Instructions

Failure to follow these instructions will result in a significant grade reduction.

Please name this document XXX_ Assignment05 where XXX are your initials.

Please see each individual JAVA problem for naming requirements.

The deliverables that are to be uploaded to the assignment are:

1) This completed document with your solutions in it. Do not remove any part of this document. (PLEASE DO NOT INCLUDE THIS DOCUMENT IN THE ZIPPED FILE). This document must be completed using Microsoft Word 2003 or newer edition of Microsoft Word. A PDF file that is compatible with myLearning may also be optionally submitted. In any case, the submitted file must open in myLearning for grading. If the file does not open in myLearning I will have nothing to grade and the result will be a zero for the assignment.

2) All Java source code in a zipped file. Please name this zip file XXX_ Assignment05 where XXX are your initials.

Precisely follow the instructions in the video “Instructions for the Submission of Homework Assignments” and watch any additional videos in the modules that discuss the homework for additional instructions.

Three of the five problems in this assignment will be graded. Any problem that is not done will receive a grade of zero.

Please see the grading rubric for this assignment; individual problem point values are shown there.

Include Header comments on all programs submitted. See Below:

/**

//***********************************************************************

‘Project: Assignment #

‘Programmer: FULL NAME

‘Company Info: EMAIL

‘Date: DD MM YYYY

‘Description: Problem Number #.

‘ LINE 1 AT LEAST 3 LINES OF PROGRAM DESCRIPTION

‘ LINE 2 AT LEAST 3 LINES OF PROGRAM DESCRIPTION

‘ LINE 3 AT LEAST 3 LINES OF PROGRAM DESCRIPTION

‘ ————————————————————————–

‘ HONOR CODE:

‘ I pledge that this program represents my own program code, I have received

‘ help from no one and I have given help to no one.

‘ OR

‘ I received help from NAME OR NO ONE in designing and debugging my program.

‘ I given help to NAME OR NO ONE in designing and debugging my program.

‘—————————————————————————–

‘ LINE LENGTH – AVOID LINES LONGER THAN 80 CHARACTERS

‘ SCALE BELOW IS TO CALIBRATE SCREENSHOTS

‘ DO NOT HAVE YOUR CODE OR SCREENSHOT EXTEND BEYOND THE SCALE

0……..1………2………3………4………5………6………7………8

12345678901234567890123456789012345678901234567890123456789012345678901234567890

*/

PLACE SCREEN SHOT OF PROGRAM CODE and CONSOLE OUTPUT HERE.

Please note that I made the screen shot using the windows snipping tool, had the appropriate comments in the program, had the program number as it was in the assignment. In addition, all code from the program is visible and legible with line numbers. In the screen shot of the console output the date and time must be shown and highlighted. If you are not familiar with the windows snipping tool video please watch it now.

Follow all applicable CSC-2591 Java Programming Standards for this assignment.

Note that for this assignment:

· The “this” construct must be exclusively used in setting instance variables for all classes.

· Stringbuilder must be used in developing toString methods.

· Use, for all work, printf or String.format for formatting of all output. Do NOT use DecimalFormat.

· Have the correct Javadoc comments as required in the programming standards.

THIS IS WHAT IS EXPECTED FROM THE SCREEN SHOT:

If you are using JOptionPane Show Screen shots of all messages and I/O for all cases, for example:

Develop a new checklist that includes all the comments that were given on your last assignment. Make sure those comments are implemented on this assignment. Use this checklist to verify that your homework submission adheres to the programming standards and rubric. Show all these items below:

PLACE ITEMS FOR CHECKLIST HERE.

1. Write two exception classes, one called MonthException and another called DayException.

PLACE SCREEN SHOT OF PROGRAM CODE AND CONSOLE PROGRAM OUTPUT HERE

Write a program that converts dates from numerical month-day format to alphabetic month-day format. For example, input of 1/31 or 01/31 would produce January 31 as output. If the user enters anything other than a legal month number (integers from 1 to 12), your program should throw and catch a MonthException. Similarly, if the user enters anything other than a valid day number (integers from 1 to either 29, 30, or 31, depending on the month), your program should throw and catch a DayException. To keep things simple, assume that February always has 28 days.

PLACE SCREEN SHOT OF PROGRAM CODE AND CONSOLE PROGRAM OUTPUT HERE

2. Please name your driver program XXX_P02 where XXX are your initials. Please name your land track class LandTrack. Input and Run Chapter 08 Programming Challenge 4. My definition of equal size means that the length of one track is equal to the length of the other track and the width of one track is equal to the width of the other track. We are not considering areas in the definition of equal size. You should hard code your input into a constructor and use (l= 200, w= 300) and (l= 100, w= 600) for the input. Run the program again use (l= 100, w= 400) and (l= 100, w= 400) for the input.

PLACE SCREEN SHOT OF PROGRAM CODE AND CONSOLE PROGRAM OUTPUT HERE

3. Create an interface StringDecoder that has a single abstract method decode(cipherText), where cipherText is the message to be decoded. The method will return the decoded message.

Create an interface StringEncoder that has a single abstract method encode(plainText), where plainText is the message to be encoded. The method will return the encoded message.

Create the following classes that implement the StringDecoder and StringEncoder interfaces.

a. Create a class called SubstitutionCipher – The constructor should have one parameter called shift. Define the method encode so that each letter is shifted by the value in shift. For example, if shift is 3, a will be replaced by d, b will be replaced by e, c will be replaced by f, and so on. (Hint: You may wish to define a private method that shifts a single character.)

b. Create a class called ShuffleCipher – The constructor should have one parameter called n. Define the method encode so that the message is shuffled n times. To perform one shuffle, split the message in half and then take characters from each half alternately. For example, if the message is abcdefghi, the halves are abcde and fghi.

Run the program with the following information:

SubstitutionCipher: use outstanding (encode and decode) ShuffleCipher: use outstanding (encode and decode)

PLACE SCREEN SHOT OF PROGRAM CODE AND CONSOLE PROGRAM OUTPUT HERE

Applied Sciences
Architecture and Design
Biology
Business & Finance
Chemistry
Computer Science
Geography
Geology
Education
Engineering
English
Environmental science
Spanish
Government
History
Human Resource Management
Information Systems
Law
Literature
Mathematics
Nursing
Physics
Political Science
Psychology
Reading
Science
Social Science
Home
Homework Answers
Blog
Archive
Tags
Reviews
Contact
twitterfacebook
Copyright © 2021 SweetStudy.com

Order Solution Now

Our Service Charter

1. Professional & Expert Writers: Topnotch Essay only hires the best. Our writers are specially selected and recruited, after which they undergo further training to perfect their skills for specialization purposes. Moreover, our writers are holders of masters and Ph.D. degrees. They have impressive academic records, besides being native English speakers.

2. Top Quality Papers: Our customers are always guaranteed of papers that exceed their expectations. All our writers have +5 years of experience. This implies that all papers are written by individuals who are experts in their fields. In addition, the quality team reviews all the papers before sending them to the customers.

3. Plagiarism-Free Papers: All papers provided byTopnotch Essay are written from scratch. Appropriate referencing and citation of key information are followed. Plagiarism checkers are used by the Quality assurance team and our editors just to double-check that there are no instances of plagiarism.

4. Timely Delivery: Time wasted is equivalent to a failed dedication and commitment. Topnotch Essay is known for timely delivery of any pending customer orders. Customers are well informed of the progress of their papers to ensure they keep track of what the writer is providing before the final draft is sent for grading.

5. Affordable Prices: Our prices are fairly structured to fit in all groups. Any customer willing to place their assignments with us can do so at very affordable prices. In addition, our customers enjoy regular discounts and bonuses.

6. 24/7 Customer Support: At Topnotch Essay, we have put in place a team of experts who answer to all customer inquiries promptly. The best part is the ever-availability of the team. Customers can make inquiries anytime.