Your instructor will assign you one of the problems below. To
solve your problem, write a program that reads the necessary
information to compute and output the indicated values, as
efficiently as possible. Following the pattern in the lab
exercise, first, *design* using OCD; then *code* your
design in C++ using stepwise translation; finally, test your
program thoroughly.

Project #11.1: Extend the class`Fraction`

by overloading the remaining arithmetic operators (`+`

,`-`

, and`/`

), the six relational operators (`==`

,`!=`

,`<`

,`>`

,`<=`

, and`>=`

). Then construct a menu-driven 4-function calculator that an elementary student can use to check his or her fraction homework assignments.In your documentation file, include some comments why

`%`

shouldnot(and is not) defined for`Fraction`

.

Project #11.2: Create a "drill" program for the`Fraction`

class. This program should generate random fractions (using class`RandomInt`

fromC++: An Introduction to Computing) that are displayed and then asks for the user to type in their product. The program checks the answer and tells the user if they were right or wrong. This would be great for grade-school kids learning fractions for the first time. Keep track of the total number of problems the user gets right and gets wrong; report this number when the program finishes.

Project #11.3: A quadratic equation has the formaxwhere^{2}+ bx + c = 0`a`

,`b`

, and`c`

are all real values. Write a class`Quadratic`

that can be used to model a quadratic equation, with operations to construct with default values, construct with explicit values, input, output, extract the instance variables of, evaluate (for a given value of`x`

), find the roots of, and find the`x`

value at which the value of the`Quadratic`

is minimized (or maximized).To test your class, write a menu-driven program that allows a user to enter a quadratic, and repeatedly process it using any of the provided operations.

Project #11.4: A phone number consists of four separate pieces of information: an area code, an exchange, a local number, and a long-distance indicator (true or false). Design and build a`PhoneNumber`

class that models a phone number, providing operations to construct, input, output, extract each of the instance variables of a`PhoneNumber`

object, and indicate whether or not the number is long-distance. The input operation should read a local or long-distance number and set the long-distance indicator accordingly. The output operation should display a local number differently from the way it displays a long-distance number (e.g.,`555-1234`

vs.`(616) 555-1234`

).To test your class, write a program that simulates an intelligent computer modem dialer by reading a

`PhoneNumber`

, and displaying the number to be dialed. If the number is a long distance number, it should be preceded by`1-`

; otherwise it should be displayed as a local number.

Project #11.5: A playing card has two attributes, itsrank(e.g., 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A) and itssuit(e.g., clubs, diamonds, hearts, spades). Design and build a`PlayingCard`

class that models a playing card. Your class should provide operations to construct, input, output, compare, and extract the instance variables of a`PlayingCard`

object.A deck of cards is simply a sequence of cards. Design and create a class

`DeckOfCards`

that represents such objects by using a`vector`

to store a sequence of`PlayingCard`

values. Your`DeckOfCards`

class should provide operations to construct, shuffle, and take the top card. The class constructor should initialize the`DeckOfCards`

as a new deck of 52 cards (i.e., 2-clubs, 3-clubs, ..., A-clubs, 2-diamonds, ..., A-diamonds, 2-hearts, ..., A-hearts, 2-spades, ..., A-spades). The shuffle operation should rearrange the cards in a deck in random order. The final operation should remove the top card from the deck, and return that card.To test your classes, write a program that plays a simple card game (i.e., blackjack, go fish, etc.) against a human opponent.

Turn the following things:

- This grade sheet.
- Your OCD.
- Your source program.
- The output from an execution of your program.

Lab Home Page | Lab Exercise

© 2003 by Prentice Hall. All rights reserved.

Report all errors to Jeremy D. Frens.