Hands On C++: Project 3b


Objectives

1. Practice designing a solution to a problem;
2. Practice using C++ selective and repetitive behavior;
3. Practice writing functions; and
4. Practice writing reuseable code.

Introduction

Your instructor will assign you one of the following problems. To solve your problem, write a program that inputs the necessary information to compute and output the indicated values, as efficiently as possible. Use object-centered design, following the example in the lab exercise, and then employ stepwise translation to encode your algorithm in C++. Use functions and separately compiled libraries where appropriate to make your code reuseable. Then test your program thoroughly, using the facilities at your disposal.

Projects

3b.1. Write a program that asks the user how many test scores they have, and then reads that many test scores, averages them, and displays the average and a pass/fail grade appropriate for that average (passing is 60 or higher, failing is below 60). Use a separately compiled function to average the input values.

3b.2. Write a "password protection" function that you can use to guard your programs. When called, this function should ask the user for a password. It should allow the user N tries at entering the correct password, where N is a value received from its caller.. If the user enters the correct password, the function returns control to its caller, where execution proceeds as normal. If the user fails to enter the correct password after N tries, then the function should use exit() from stdlib.h to terminate the program. Store your function in a separately compiled library, so that different programs can share it.

3b.3. Proceed as in 3b.1, but instead of displaying a pass/fail grade, the program should compute a "normal" letter grade (90-100 = A, 80-89 = B, 70-79 = C, 60-69 = D, ...).

3b.4. Write two functions:

Your functions should check the value of n is positive; if not, they should display an informative error message and return 0.

Store them in a separately compiled library. Write a driver program that lets the user apply either of these functions to an input value, displaying the result.

Turn In: A hard copy of this grade sheet, attached to hard copies of

  1. your design for this project;
  2. your Makefile for this project;
  3. all source files you create for this project; and
  4. the output from an execution of your executable program (using script).

Don't forget to clean up your directory when you are all finished...


Back to the Lab Exercise

Back to This Lab's Home Page


Copyright 1998 by Joel C. Adams. All rights reserved.