Hands On C++: Project 2


Objectives

1. Gain further experience constructing expressions.
2. Gain further experience writing programs.

Introduction

Each of the following projects involves the construction of expressions of various types, and so will provide practice in building expressions. Your instructor will tell you which one to do.

Projects

2.1. Finish the lab exercise by completing the remaining experiments.

2.2. Write a program that finds the resistance of an electronic circuit with three parallel resistors resistor1, resistor2, and resistor3. The resistance can be computed using the following formula:

                                   1
   resistance = -------------------------------------- 
                      1            1            1
                 ---------- + ---------- + ----------
                 resistor1    resistor2    resistor3

2.3. The two solutions of a quadratic equation

   y = ax2 + bx + c
can be found using the quadratic formula:
   solution1 = -b + the square root of (b2 - 4ac)
               -----------------------------------
                              2a
and
   solution2 = -b - the square root of (b2 - 4ac)
               -----------------------------------
                              2a
Write a program that inputs values for a, b and c, and outputs the values of solution1 and solution2. Use boolean expressions and the assert() mechanism to ensure that

2.4. Write a program that, given the amount of a purchase and the amount received in payment, computes the change in dollars, half-dollars, quarters, dimes, nickels and pennies.

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

  1. your source program; and
  2. the output from three executions 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.