INFO-I211 Lab 2
Data and Expressions

Due date: see Oncourse Modules or Assignments
50 points

Learning Objectives

  1. Facility with Java arithmetic operations and input using the Scanner class.
  2. Ability to use Unix I/O redirection, pipes, wildcards, and the Unix online manuals.

Part A: Java Programming

Prerequisite: Lewis and Loftus, Chapter 2.

Required: Programming Project PP 2.8, page 109, converting time duration in hours, minutes, seconds to time duration in seconds.

Test the program with these test cases, and capture the test I/O as described in Lab 1.

Case 1
0 hours, 0 minutes, and 42 seconds
Case 2
0 hours, 2 minutes, and 24 seconds
Case 3
4 hours, 0 minutes, and 0 seconds
Case 4
3 hours, 0 minutes, and 30 seconds
Case 5
6 hours, 19 minutes, and 26 seconds

Turn in the source code and test output files in Oncourse Assignments.

Part B: Unix I/O, Wildcards, and Help

  1. Prerequisite: Unix Tutorial 1–2.
  2. Read the UNIX/Linux Tutorial for Beginners: Part 3 and Part 4. These parts cover redirection of input and output, pipes, wildcards, file naming conventions, and getting help.
  3. Use a text editor to create an input file "time.in" with three lines of input (three times in hours, minutes, seconds) for your Java time conversion program. Run the time conversion program, redirecting input to "time.in" and output to "time.out". Use cat to dump the output file to the screen.
  4. Run the time conversion program again, redirecting input to "time.in" but this time piping the output to sort or to wc.
  5. Use the ls command with wildcards to list the files in your working directory where (a) the file name begins with "time"; (b) the file name ends with ".java"; (c) the file name ends with ".class"; (d) the file name contains an "i" anywhere.
  6. List the files in your working directory sorted by file modification time. Use man ls to learn how to do this. (Hint: look at the command line options like -a.)

This part is ungraded.

Grading Criteria

ItemPoints
Source code is correct. 30
Source code shows good style. 10
Tested with required test data. 10
Total50

The Coding Standards for Chapters 1–2 apply to this assignment.

The late policy described in the syllabus applies to this assignment.