 # Calculator Using C++ Programming

## Question

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.

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

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

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#ifndef VECTOR_H
#define VECTOR_H

#include <iostream>
using namespace std;
class Vector {
public:
Vector();
Vector(float u, float v, float w);
Vector(const Vector& orig);
virtual ~Vector();
void setU(int u);
void setV(int v);
void setW(int w);
int getU()const;
int getV()const;
int getW()const;
void setVector(float u, float v, float w);

Vector operator + ( const Vector & op2);
Vector operator - (const Vector & op2);
float operator * (const Vector & op2);
Vector operator / (const Vector & op2);
Vector operator = (const Vector & op2);

friend ostream &operator<<(ostream &stream, Vector a);
friend istream &operator>>(istream &stream, Vector &o);private:
float vt;
};...
\$73.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.