CS 2620 Assignment #1 Summer 2003

How to handin.
Points : 25
Weight : 3%
Due : Friday May 14, 2004 @11:00 PM
Note : Late assignments will be accepted only with the instructor's pre-approval.
Marks will be awarded for comments, style, readability, compiling and working correctly.
  1. [10] Using the cctype library and character input.
    Write a program which asks the user for input and reports the following statistics :
    1. the total number of characters in the input
    2. the total number of lines in the input
    3. the total number of letters in the input
    4. the total number of digits in the input
    The program should continue reading until it finds an END OF FILE.
    Note: You will need to use a get function for input since you need to process all characters.

  2. [10] Write a program that will allow a user to work with points. The program should be able to read two points, print the distance between the points, print the point that is ½ way between the two points. Use good procedural abstraction. You will need to write functions to read a point, print a point, find the distance between two points and calculate the midpoint.

    Points must have one of the following formats:

    1. (a,b)
      • a and b are real numbers
      • it starts with a ( and ends with a )
      • there is a comma between a and b
      • there may be any number of spaces between the components
    2. a b
      • a and b are real numbers
      • no other non-space characters are allowed
      • there may be any number of spaces between the components
  3. [5] Create a point library that contains the functions written for the program in part 2. Write a simple test program which uses this library.

Assignment List | Next | Computer Science 2620
Department of Mathematics & Computer Science
University of Lethbridge Home Page