CS 210 – Fundamentals of Programming I
Spring 2007 – Programming Assignment 4
20 points
Out: February 6/7
Due: February 13/14 (same day as Exam 1)


(6 points) Write an analysis and design for a function named ConvertTime that converts a time in military format (i.e., 24-hour notation, 0000 to 2359) into standard format (i.e., 12-hour notation with AM/PM, 12:00AM to 11:59PM). For example, 1425 converts to 2:25PM. The function receives the military time and must pass back the hours, minutes, and AM/PM information of standard time. (I.e., this function will have 4 parameters and there must not be any display steps in the function.) The AM/PM information should be represented by a value of type char, 'A' for AM and 'P' for PM.


Use the format shown in class and in the on-line handout An Analysis and Design Style Guideline. Write this part as a comment block in the implementation source file as the function header as shown in the on-line handout A C++ Programming. Style Guideline for CS 210.


(14 points) Implement an entire program in C++ that will repeatedly ask the user for a time in military format and display the equivalent time in standard format. It must use the function you designed above to compute the equivalent time in standard format. The display of the standard time format must be done in the main program. The program does not need to handle invalid times. The output might look something like:


This program converts time in military format into standard format.

Please enter a time in military format: 1215.
The equivalent time in standard format: 12:15PM

Would you like to do another conversion (y/n)? y

Please enter a time in military format: 0030.
The equivalent time in standard format: 12:30AM

Would you like to do another conversion (y/n)? y

Please enter a time in military format: 2325.
The equivalent time in standard format: 11:25PM

Would you like to do another conversion (y/n)? n

Follow the guidelines in the on-line handout A C++ Programming. Style Guideline for CS 210. As stated in the syllabus, part of the grade on a programming assignment depends on how well you adhere to the guidelines. The grader will look at your code listing and grade it according to the guidelines.


Electronically submit your source file (the .cpp file) by emailing it as an attachment to cs210@csserver.evansville.edu by 5pm on the due date. (Make sure you send it to csserver.evansville.edu. If you send to just evansville.edu, it will not be delivered.)


Please note: If you write this program using a system other than Visual Studio, please make sure that your program will compile and run under Visual Studio before you turn it in. Also check that the code is formatted correctly under the Visual Studio editor.

02/05/07 2