CSCI 220
HOMEWORK ASSIGNMENT #1
Assigned Date: Tuesday, January 27, 2004
Due Date: Tuesday, February 3, 2004
Due Time: Noon

 

Introduction:

“A dollop of variables and a dash of comments are proper ingredients, but good programming (like good cooking) takes talent that doesn’t come with the cookbook.  Instructors at restaurant schools realize this, and begin their courses by teaching prospective chefs the Zen of boiling water or breaking eggs.” [1] Approach this assignment in this frame of mind.

 

Purpose:

This assignment focuses on creating, compiling and executing a Java program. In addition, it incorporates I/O and simple arithmetic manipulations.

Source filename to be submitted:  TimeConverter.java

 

Documentation:

All programs that you complete in your career as a student and as a professional should be fully documented.  Follow the Golden Rule of Style: “A program should be as easy for a human being to read and understand as it is for a computer to execute.” [2] 

You should always include opening comments that state the author of the file, the date, documentation of resources used to write the code, and comments related to the code and its functionality.  This semester your opening comment section for every program you submit should have the following format.   

/*

   Author:     <Your Name>
   Email:      <Your email address> 
   Class:      CSCI 220, Section <Your section number> 
   Assignment: HMWK1
   Due Date:   <The assignment's due date>

   Certification of Authenticity <include one of the following>:   

      I certify that this lab is entirely my own work.

      I certify that this lab is my own work, but I received
      some assistance from:  <Name(s)>

   Task: <Provide a simple, yet complete description of the task being
         performed by this program. It may be several sentences long.>

   Input: <Provide a simple, yet complete description of the input required
          by this program.>

   Output: <Provide a simple, yet complete description of the output generated
          by this program.>

*/

 

Also apply the departmental Java Coding Standards (as they pertain to this assignment).  Points will be deducted for programs that are not properly documented.

 

Assignment: 

Write a program that inputs the time in seconds and converts it to the corresponding time in hours, minutes, and seconds.

 

Sample Run 1: (user input in italics)

Enter time in seconds (a non-negative integer): 28882

This is equivalent to 8 hour(s), 1 minute(s), and 22 second(s).

 

Sample Run 2: (user input in italics)

Enter time in seconds (a non-negative integer): 136

This is equivalent to 0 hour(s), 2 minute(s), and 16 second(s).

 

Notes:

  1. You may assume that the input to your program is error-free, i.e., the user will input a non-negative integer.
  2. Follow the above I/O format carefully.
  3. Test your program with different inputs to ensure that it works properly.

 

Submission: 

You should submit your source file on a floppy disk.  Clearly label your floppy disk with your name, course number, section number, and semester.  Place your program at the top directory (no subdirectories). Failure to follow these simple instructions will result in loss of points.

To be eligible for partial credit, your submitted program should compile (have no syntax errors).  Also your floppy disk should be readable on MS Windows.

 

References

  1. Cooper, D. and Clancy, M. (1985) “Oh! Pascal”, 2nd ed., W.W. Norton & Company, New York, p. 41
  2. ibid., p. 42.