// Nathan ELoe 4/11/2013
// driver.cpp
// Vector math and basic arithmetic calculator
#include "utils.h"
#include "vector.h"
#include "templates.h"
#include <iostream>
const int MENU1LEN = 4;
const string MENU1[MENU1LEN] = {"Enter two values",
"Add values",
"Multiply Values",
"Quit"};
const int MENU2LEN = 3;
const string MENU2[MENU2LEN] = {"Reals", "Integers", "Vectors"};
const int REAL = 1;
const int INT = 2;
const int VEC = 3;
int main()
{
int ival1, ival2;
double dval1, dval2;
vector3D vval1, vval2;
bool haveInt = false, haveReal = false, haveVec = false;
int choice = 0, type = 0;
cout << "Welcome to the calcumatic-a-majig!" << endl;
while (choice != MENU1LEN)
{
formatMenu(MENU1, MENU1LEN);
choice = getBoundedInt(1, MENU1LEN);
if (choice != 4 && (choice == 1 || (choice != 1 && (haveInt || haveReal || haveVec))))
{
formatMenu(MENU2, MENU2LEN);
type = getBoundedInt(1, MENU2LEN);
cout << endl;
}
else if (choice != 4)
{
cout << "Please enter values first!" << endl;
choice = 0;
}
switch (choice)
{
case 1:
if (type == REAL)
{
input(dval1);
input(dval2);
haveReal = true;
}
else if (type == INT)
{
input(ival1);
input(ival2);
haveInt = true;
}
else
{
input(vval1);
input(vval2);
haveVec = true;
}
break;
case 2:
cout << "Sum: ";
if (type == REAL && haveReal)
cout << add(dval1, dval2);
else if (type == INT && haveInt)
cout << add(ival1, ival2);
else if (type == VEC && haveVec)
cout << add(vval1, vval2);
else
cout << "No values entered. Enter values first.";
cout << endl;
break;
case 3:
cout << "Product: ";
if (type == REAL && haveReal)
cout << mult(dval1, dval2);
else if (type == INT && haveInt)
cout << mult(ival1, ival2);
else if (type == VEC && haveVec)
cout << mult(vval1, vval2);
else
cout << "No values entered. Enter values first.";
cout << endl;
break;
}
cout << endl;
}
cout << "Thank you for using the calcumatic. Have a nice day." << endl;
return 0;
}