Project 3


Total Points:                           10 pts.

Overview
Develop an interactive multi-purpose calculator to input, calculate, and display results for operations on a variety of mathematical types. The different types include a basic Floating-point type, a Vector type, and a Fraction type. Write a system that allows a user to perform basic operations on each of these types by entering the type of calculator, operation, and left and right operands. The system will perform the selected operation, print the results, and continue until the user terminates the session. The different calculator types and specific operations on each type will be discussed in class and shown below. Design notes will be collected and graded as part of the project grade.

Specifically, your tasks will be to:

1) Design your system with classes to implement the different calculator types (floating-point, vector, fraction).

 

2) Operate on the different types in each of your calculator classes, you must also design and implement classes for the new types themselves (i.e. vector class, fraction class).  Each of your classes MUST contain overloaded operator member methods to perform the various arithmetic operations.

 

3) Design and develop your C++ classes to accurately represent the data models and the tasks operating on the data models.  As we've been practicing, each class must have both a header file (.h) and a source file (.C).  To simplify file management, you may include the classes needed for each of the calculators in the calculator classes themselves (i.e. vector class can be included in vector calculator class).

 

4) Begin a session with your multi-purpose calculator by prompting the user to select the calculator type.  After selection, prompt the user for the operation to perform as well as the left and right operands in the type format selected (i.e. vectors will require 3 floating-point numbers).

 

5) Print the results in a format showing the requested expression (i.e. leftOp <op> rightOp = result) in proper format (i.e. vector results will be 3 floating-point numbers) and continue until the user requests termination of the session.
 

Design
Develop your data models by using the design methodology discussed in the study notes. Document organized, well-written design notes that capture what each of the models "knows" and "does" in a table format (similar to designs in the study notes). With the importance of design in software development, these design tables will be handed in as part of the project submission and graded as part of the project grade. Write up your design tables in either text or Microsoft Word format files and include in your project folder submission. As discussed in lecture, object-oriented program development begins with thinking about solutions differently. An essential element to well-developed OO programs is the identification, design, and construction of robust data models to reflect the program specification. From the project description, identify, design, and develop at least 2 new classes for this project to receive full credit. Design and develop your C++ classes to accurately represent the data models and the tasks operating on the data models. As in the study notes, put each class definition in its own header file (.h), each class member function definitions in its own source file (.C), and the program application in its own source file (project2.C).
 
 

Calculator Types

Floating-point
left, right operands and result - floating point values

+ symbol:  addition of left and right operands

left + right = result

 

- symbol:  subtraction of left and right operands

left - right = result

 

* symbol:  multiplication of left and right operands

left * right = result

 

/ symbol: division of left and right operands

left / right = result

 

Vector
left, right operands - 3 component vectors (float u, float v, float w)
result - 3 component vectors (for +, -, /), single floating-point scalar (for *)

+ symbol:  addition of left and right operands

left + right = result

 

where

 

result0 = <left0 + right0>
result1 = <left1 + right1>
result2 = <left2 + right2>

 

- symbol:  subtraction of left and right operands

left - right = result

 

where

 

result0 = <left0 - right0>
result1 = <left1 - right1>
result2 = <left2 - right2>


* symbol:  dot product of 2 vectors

left * right = result

 

where

 

result = (left0 * right0) + (left1 * right1) + (left2 * right2)

 

 

/ symbol: cross product of 2 vectors

left / right = result

 

where

 

result0 = (left1 * right2) - (right1 * left2)
result1 = -( (left0 * right2) - (right0 * left2) )
result2 = (left0 * right1) - (right0 * left1)

 

Fractions
left, right operands and result - (integer numerator) / (integer denominator) (i.e. fractions 1/2)

left = n1/d1
right = n2/d2
result = rN/rD

 

+ symbol:  addition of left and right operands

left + right = result

 

where

 

rN = n1*d2 + n2*d1
rD = d1*d2


- symbol:  subtraction of left and right operands

left - right = result

 

where

 

rN = n1*d2 - n2*d1
rD = d1*d2


* symbol:  multiplication of left and right operands

left * right = result

 

where

 

rN = n1*n2
rD = d1*d2

 

/ symbol: division of left and right operands

left / right = result

 

where

 

rN = n1*d2
rD = d1*n2