f11csc210-hw2 - CSC 210.03/210.04 Fall 2011...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSC 210.03/210.04 Fall 2011 Instructor: Marc Sosnick Homework 2 (15 points) Due: Midnight, Friday, September 9, 2011. Description: In this assignment, you will: A. Write an algorithm B. Turn the algorithm into comments C. Turn the comments into a program There is an optional extra ­credit task that allows you to explore getting input from and displaying data in dialog boxes. See the extra credit section below for more detailed descriptions. Submission: Submit a PDF containing, each on a separate page: 1) Your algorithm (use a word processor or text editor) 2) Your algorithm turned into comments inside the main method. 3) The source code (including your algorithm as comments) 4) The output of a run of your program (see Homework 1 for instructions on how to do this), including user interaction (i.e. data entered from the keyboard) Remember, for full credit your PDF must be in a fixed with font such as Courier or Monaco, and have your name, email address, date, class and section and assignment at the top of the document. Please see the extra credit section for additional submission requirements for extra credit. Problem: Develop an algorithm to calculate information about a box (i.e. rectangular cubiod, see cuboid on Wikipedia for specifics). The user should enter measurement information about the box from the console. Results should be displayed on the console. The program should calculate and display the volume and surface area of the box (rectangular cuboid) based on the data entered. Measurements should be in centimeters, and should be able to be entered to an accuracy of at least 1/10th of a cm. 1 Tips: 1. Be sure that you use good programming style: a. Remember to initialize your variables b. Use descriptive variable names c. Code and comments should be indented correctly d. Use descriptive comments (Hint: use your algorithm comments as a starting point, add more comments if necessary) e. There should be a descriptive, well ­formatted comment block at the head of the file that includes your name, the name of the file, assignment, date, class and description of the program. 2. Use the correct variable types (e.g. int vs. double) 3. Use the Scanner class to get input from the user on the console. Detailed Description 1. Write an Algorithm to Solve The Problem As we did in class, develop a step ­by ­step algorithm that solves the problem as stated above. This should include getting user input, displaying output, and doing calculations for the required information. Write this algorithm using standard English. For example (for a different problem): Travel Time Calculator Get distance. Get rate of travel. Calculate time ( distance * rate of travel). Report to user. 2. Turn the Algorithm into Comments As we did in class, turn your algorithm into comments, and put the comments inside the main method of a new program in a new project. This corresponds to step 2 above, and must be separate (i.e. you must do this as a program, cut ­and ­paste, then do the next step, then cut ­and ­paste) from the following step. You do not need to include output from this program. For example: public class TravelTimeCalulator { public static void main(String args){ // Get distance // Get rate of travel // Calculate time // Report to user } } 2 3. Turn the Comments into a Program As we did in class, beneath each comment, program the steps necessary to perform that part of the algorithm. This should be cut ­and ­pasted below the program developed in step 2. 4. Run Program and Cut ­and ­Paste Results Run your program. Cut and paste the results into your document. Extra Credit (3 points) Important note: Extra credit does not replace the assignment submission requirements above, but is in addition to the submission requirements above. In other words, you must first complete the regular homework assignment, including collecting and printing output for the program. No credit will be given for the assignment if the regular assignment above itself is not submitted. Description: Use dialog boxes to get user input and to display results for the program developed above. See §1.9 and §2.18 in the book. Extra Credit Submission: 1) In the same PDF as your homework, cut and paste your extra credit source code on a new page. 2) Screenshots of each of the dialog boxes pasted into page(s) of the PDF. V2.0 020311 3 ...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online