/** \brief Set this employee the values recived as parameters
 *
 * \param pEmployee employee*
 * \param id int
 * \param name[] char
 * \param lastName[] char
 * \param salary float
 * \param sector int
 * \return int Return (-1) if Error [NULL pointer] - (0) if Ok
 *
 */
Employee* newEmployee(void)
{
    Employee* returnAux = NULL;
    Employee* pEmployee = malloc(sizeof(Employee));
    if(pEmployee != NULL)
    {
        int legajo=getValidInt("\nIngrese legajo:","\nError, reingrese...",1,10000);
        pEmployee->id=legajo;

        char apellido[51];
        getValidString("\nIngrese apellido del empleado:","\nError, reingrese...",apellido);
        strcpy(pEmployee->lastName,apellido);

        char nombre[51];
        getValidString("\nIngrese nombre del empleado:","\nError, reingrese...",nombre);
        strcpy(pEmployee->name,nombre);

        pEmployee->salary=getFloat("\nIngrese sueldo:");

        pEmployee->isEmpty = 0;

        returnAux = pEmployee;
    }
    return returnAux;
}
Beispiel #2
0
int deleteData(eMovie *movie,int length)
{
    int retorno=-1;
    int dato;
    if(movie!=NULL && length>0)
    {
        if(campolleno(movie,QTY)==1)//1 nada cargado, -1 null y 0 cargaprevia
        {
            int datoEncontrado;
            dato = getValidInt("Ingrese el codigo de la pelicula a borrar","Ingrese codigo numerico\n",1,1000);
            datoEncontrado = searchInt(movie,length,dato);
            if(datoEncontrado==-1)//searchInt devuelve menos 1 cuando no esta cargado.????
            {
                printf("Codigo no encontrado");

            }
            movie[datoEncontrado].status = -1;
            printf("Los datos han sido borrados");//-1
            retorno = 0;
        }
        else
        {
            printf("No hay datos cargados\n");
        }
    }
    return retorno;

}
Beispiel #3
0
//allows tutor to enter additional availability from the terminal
istream& Tutor::enterAvailability(istream &in)
{
    cout << "How many available times do you have (greater than 0): ";
    
    numTimes = getValidInt(in);
    
    while(numTimes <= 0 || numTimes > 20)
    {
        cerr << "Enter a valid number of times (between 0 and 20): ";
        
        numTimes = getValidInt(in);
    }
    
    Time newAvailability;
    
    for(int i = 0; i < numTimes; i++)
    {
        cout << "***Prepare to enter availability #" << (i + 1) << "***" << endl;
        in >> newAvailability;
        avail[i] = newAvailability;
    }
    
    cout << "How many subjects do you tutor (between 0 and 5): ";
    numSubjects = getValidInt(in);
    
    while(numSubjects <= 0 || numSubjects > 5)
    {
        cerr << "Enter a valid number of subjects (between 0 and 5): ";
        
        numSubjects = getValidInt(in);
    }
    
    std::string newSubject;
    
    for(int i = 0; i < numSubjects; i++)
    {
        cout << "***Prepare to enter subject #" << (i + 1) << "***" << endl;
        in >> newSubject;
        subjects[i] = newSubject;
    }

    return in;
}
Beispiel #4
0
//inputs availability from a file
ifstream& Tutor::enterAvailability(ifstream &in)
{
    
    numTimes = getValidInt(in);
    
    while(numTimes < 0 || numTimes > 20)
    {
        numTimes = getValidInt(in);
    }
    
    Time newAvailability;
    
    for(int i = 0; i < numTimes; i++)
    {
        in >> newAvailability;
        avail[i] = newAvailability;
    }
    
    numSubjects = getValidInt(in);
    
    while(numSubjects < 0 || numSubjects > 5)
    {
        
        numSubjects = getValidInt(in);
    }
    
    std::string newSubject;
    
    for(int i = 0; i < numSubjects; i++)
    {
        in >> newSubject;
        subjects[i] = newSubject;
    }
    
    return in;
}
void adminBooks(book bookArray[])
{
    // variables auxiliares
    char titleAux[51];

    int authorIdAux;
    int codeAux;
    int stockAux;
    //________________________________________________

    int freePlaceIndex;
    int foundIndex;
    int option = 0;

    while(option != 6)
    {
         system("@cls||clear");
         printf("\n------------  ABM LIBROS ------------");
         option = getInt("\n1 - ALTA \n2 - BAJA \n3 - MODIFICACION\n4 - LISTAR\n5 - ORDENAR\n6 - REGRESAR\n\n\n");
         switch(option)
         {
            case 1: // ALTA DE LIBRO

                freePlaceIndex = findBookEmptyPlace(bookArray,MAX_QTY);
                if(freePlaceIndex == -1)
                {
                    printf("\n\nNO QUEDAN LUGARES LIBRES!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                codeAux = getValidInt("Ingrese el codigo del libro: ","El codigo del libro debe ser numerico\n", 1, 15000);
                if(findBookByCode(bookArray,MAX_QTY,codeAux) != -1)
                {
                    printf("\n\nEL CODIGO YA EXISTE!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                authorIdAux =  getValidInt("Ingrese el ID del autor del libro: ","El ID del autor debe ser numerico\n", 1, 500);

                stockAux = getValidInt("Ingrese la cantidad de libros: ","La cantidad debe ser numerica\n", 1, 10000);

                getValidString("Ingrese el titulo: ","El titlo debe estar compuesto solo por letras\n", titleAux);

                setBook(bookArray,freePlaceIndex,codeAux,titleAux,authorIdAux,stockAux);

                break;

            case 2: // BAJA LIBRO

                codeAux = getValidInt("Ingrese el codigo de libro a dar de baja: ","El codigo del libro debe ser numerico\n", 1, 15000);
                foundIndex = findBookByCode(bookArray,MAX_QTY,codeAux);
                if(foundIndex == -1)
                {
                    printf("\n\nNO SE ENCUENTRA ESE CODIGO\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }
                bookArray[foundIndex].status = 0;
                break;

            case 3: // MODIFICAR LIBRO

                codeAux = getValidInt("Ingrese el codigo del libro a modificar: ","El codigo del libro debe ser numerico\n", 1, 15000);
                foundIndex = findBookByCode(bookArray,MAX_QTY,codeAux);
                if(foundIndex == -1)
                {
                    printf("\n\nNO SE ENCUENTRA ESE CODIGO\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }


                authorIdAux =  getValidInt("Ingrese el ID del autor del libro: ","El ID del autor debe ser numerico\n", 1, 500);

                stockAux = getValidInt("Ingrese la cantidad de libros: ","La cantidad debe ser numerica\n", 1, 10000);

                getValidString("Ingrese el titulo: ","El titulo debe estar compuesto solo por letras\n", titleAux);

                setBook(bookArray,foundIndex,codeAux,titleAux,authorIdAux,stockAux);

                break;

            case 4: // LISTAR
                system("@cls||clear");
                showBookArray(bookArray,MAX_QTY);
                getChar("\n\nENTER (para continuar)");
                break;

            case 5: // ORDENAR
                orderBookArrayByTitle(bookArray,MAX_QTY);
                getChar("\n\nOrdenados. ENTER (para continuar)");
                break;


         }
    }
}
void adminAuthors(author authorArray[])
{
    // variables auxiliares
    char nameAux[51];
    char lastNameAux[51];
    int authorIdAux;
    //________________________________________________

    int freePlaceIndex;
    int foundIndex;
    int option = 0;

    while(option != 4)
    {
         system("@cls||clear");
         printf("\n------------  ABM AUTORES ------------");
         option = getInt("\n1 - ALTA \n2 - BAJA \n3 - LISTAR\n4 - REGRESAR\n\n\n");
         switch(option)
         {
            case 1: // ALTA DE autor

                freePlaceIndex = findAuthorEmptyPlace(authorArray,MAX_QTY);
                if(freePlaceIndex == -1)
                {
                    printf("\n\nNO QUEDAN LUGARES LIBRES!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                authorIdAux = getValidInt("Ingrese el codigo del autor: ","El codigo del autor debe ser numerico\n", 1, 500);
                if(findAuthorById(authorArray,MAX_QTY,authorIdAux) != -1)
                {
                    printf("\n\nEL CODIGO YA EXISTE!!!\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }

                getValidString("Ingrese el nombre del autor: ","El nombre debe estar compuesto solo por letras\n", nameAux);

                getValidString("Ingrese el apellido del autor: ","El nombre debe estar compuesto solo por letras\n", lastNameAux);

                setAuthor(authorArray,freePlaceIndex,authorIdAux,nameAux,lastNameAux);

                break;

            case 2: // BAJA AUTOR

                authorIdAux = getValidInt("Ingrese el codigo del autor: ","El codigo del autor debe ser numerico\n", 1, 500);
                foundIndex = findAuthorById(authorArray,MAX_QTY,authorIdAux);
                if(foundIndex == -1)
                {
                    printf("\n\nNO SE ENCUENTRA ESE CODIGO\n");
                    getChar("\n\nENTER (para continuar)");
                    break;
                }
                authorArray[foundIndex].status = 0;
                break;

            case 3: // LISTAR
                system("@cls||clear");
                showAuthorArray(authorArray,MAX_QTY);
                getChar("\n\nENTER (para continuar)");
                break;


         }
    }
}
int menu(char mensaje[])
{
    int opcion=getValidInt(mensaje,"error al ingresar opcion",1,1000);
    return opcion;
}
Beispiel #8
0
void modify(eMovie *movie,int length)
{
    int codeAux;
    int option,ratingAux,durationAux;
    char titleAux[30],genreAux[50],linkAux [30],descriptionAux[30];

    if(campolleno(movie,QTY)==1)//0 nada cargado, -1 null y 1 cargaprevia
    {
        codeAux = getInt("Ingrese codigo de la pelicula a modificar\n");

        int i;
        for(i=0; i<length; i++)
        {
            if(movie[i].code==codeAux)
            {

                while(option!=7)
                {
                    option= getInt("\n 1- Titulo \n 2- Genero \n 3- Duracion \n 4- Descripcion\n 5- Puntaje\n 6- Link de imagen\n 7- Salir\n\n Ingrese una opcion: \n");
                    switch(option)
                    {
                    case 1: //titulo


                        getValidString("Ingrese titulo de la pelicula: \n","El titulo tiene que ser alfabetico",titleAux);
                        //fflush(stdin);
                        strcpy(movie[i].title,titleAux);
                        printf("Se cargo nuevo titulo %s\n", movie[i].title);
                        break;

                    case 2: //genero

                        //printf("%s\n", movie[i].genre);
                        getValidString("Ingrese genero de la pelicula: \n","El genero tiene que ser alfabetico",genreAux);
                        strcpy(movie[i].genre,genreAux);

                        break;

                    case 3://duracion

                       // printf("%d\n", movie[i].duration);
                        durationAux=getValidInt("Ingrese duracion total en minutos :\n","Ingrese datos numericos",30, 500);
                        movie[i].duration = durationAux;


                        break;

                    case 4:// descripcion


                        printf("la descripcion de la pelicula es: %s,\n", movie[i].description);
                        getString("Ingrese nueva descripcion: \n",descriptionAux);
                        strcpy(movie[i].description,descriptionAux);
                        break;


                    case 5://puntaje


                      //  printf("%d\n", movie[i].rating);
                        ratingAux = getValidInt("Ingrese nueva puntuacion :\n","Ingrese datos numericos",1, 100);
                        movie[i].rating= ratingAux;

                        break;
                    case 6://link

                        printf("El link de la pelicula es: %s,\n", movie[i].link);
                        getString("Ingrese nuevo link: \n",linkAux);
                        strcpy(movie[i].link, linkAux);
                        break;

                    case 7:
                        break;
                    default:
                        printf("Ingrese opcion de menu valida\n");

                    }//endSwitch

                }//cierre while

            } //cierre del if


        }

    }else
        {
          printf("No hay datos cargados para poder modificar\n");
        }
}
Beispiel #9
0
int addMovie(eMovie *movie,int length)
{
    int retorno = -1;
    int codeAux;
    char titleAux[50];
    char descriptionAux[1000];
    char genreAux[30];
    int ratingAux;
    int durationAux;
    char linkAux[300];
    int freeIndex;

    if(movie!=NULL && length>0)
    {

        freeIndex = searchFreePlace(movie,QTY);//si status==0 retorna el indice, sino 1.
        //printf("%d",freeIndex);
        if(freeIndex==-1)
        {
            printf("No hay mas espacio\n");
            //break; //cdo estaba en el case del main
        }

        codeAux=getValidInt("Ingrese codigo de pelicula: \n","Ingrese codigo numerico\n",1,1000);
        if(searchInt(movie,QTY,codeAux)!=-1)
        {
            printf("El codigo ya existe\n");
            // break;
        }
        else
        {
        getValidString("Ingrese titulo de la pelicula: \n","El titulo tiene que ser alfabetico",titleAux);

        fflush(stdin);

        getValidString("Ingrese descripcion de la pelicula: \n","La descripcion tiene que ser alfabetica",descriptionAux);
        fflush(stdin);
        getValidString("Ingrese genero de la pelicula: \n","El genero tiene que ser alfabetico",genreAux);
        fflush(stdin);
        durationAux=getValidInt("Ingrese duracion total en minutos :\n","Ingrese datos numericos",30, 500);
        fflush(stdin);
        ratingAux = getValidInt("Ingrese puntuacion :\n","Ingrese datos numericos",1, 100);
        fflush(stdin);
        //printf("LINK : %s",linkAux);
        system("pause");
        getStringL("Ingrese link de la pelicula: \n",linkAux);
        printf("link : %s\n",linkAux);
        fflush(stdin);
        setMovie(movie,freeIndex,codeAux,titleAux,descriptionAux,genreAux,durationAux,ratingAux,linkAux);
        printf("\nTitulo %s\nDuracion %d\n%s\n%s\n %d\n", movie[freeIndex].title,movie[freeIndex].duration,movie[freeIndex].description,movie[freeIndex].genre,movie[freeIndex].status);
        retorno=0;

        }



    }
    return retorno;


}
Beispiel #10
0
void Interface::menu()
{
    //instantiate polynomials of different data types for use by user
    Polynomial<int> p1, p2, p3;
    Polynomial<float> p4, p5, p6;
    Polynomial<double> p7, p8, p9;
    Polynomial<Complex> p10, p11, p12;
    
    //instantiate additional variables for use by user
    int number = 5;
    float number2 = 3.2;
    double number4 = 3.2;
    Complex number3 (2, 0);
    
    int x = 0;
    Complex x1;
    
    //determines when to exit menu
    bool goAgain = true;
    
    //used for user input in navigating menu 
    int choice, operation;
    
    //begins menu loop, menu does not exit until user asks to exit
    while (goAgain)
    {
        //asks user what data type they would like to work with on this iteration
        //Test Driver allows user to test every data type with each requirement
        cout << "Welcome to the Polynomial Machine!  Please choose a data type for your Polynomial: " << endl;
        cout << "1 - int" << endl;
        cout << "2 - float" << endl;
        cout << "3 - double" << endl;
        cout << "4 - Complex" << endl;
        cout << "5 - Run Test Driver Instead (tests all functionality)" << endl;
    
        choice = getValidChoice();
        
        //goes to case corresponding to choice above
        switch (choice)
        {
            //if user chooses integer, prompted to enter 2 int polynomials    
            case 1:
                cout << "Input the first integer term: " << endl;
                cin >> p1;
                
                cout << "Input the second integer term: " << endl;
                cin >> p2;
                
                //user prompted to choose operation to perform on polynomials
                cout << "Select the operation you wish to perform: " << endl;
                cout << "1 - Equality/Replace" << endl;
                cout << "2 - Add" << endl;
                cout << "3 - Multiply" << endl;
                cout << "4 - Evaluate" << endl;
                cout << "5 - Write to File" << endl;
                
                operation = getValidOperation();
                
                //carries out operation selected by user above
                switch (operation)
                {
                    case 1:
                        cout << "Setting polynomial 1 equal to polynomial 2 yields polynomial 1: " << endl;
                        p1 = p2;
                        cout << p1 << endl;
                        break;
                    case 2:
                        cout << "Adding polynomial 1 and polynomial 2 yields: " << endl;
                        p3 = p1 + p2;
                        cout << p3 << endl;
                        break;
                    case 3:
                        cout << "Multiplying polynomial 1 and polynomial 2 yields: " << endl;
                        p3 = p1 * p2;
                        cout << p3 << endl;
                        break;
                    case 4:
                        cout << "Enter a value for evaluation: " << endl;
                        x = getValidInt();
                        cout << "Evaluating polynomial 1 with " << x << " yields: " << endl;
                        cout << p1.evalPoly(x) << endl;
                        break;
                    case 5:
                        cout << "The first polynomial was written to \"output.txt\""<< endl;
                        p1.writeToFile();
                }
                
                break;
            
            //if user chooses float, prompted to enter 2 float polynomials     
            case 2:
                cout << "Input the first float term: " << endl;
                cin >> p4;
                
                cout << "Input the second float term: " << endl;
                cin >> p5;
                
                //user prompted to choose operation to perform on polynomials
                cout << "Select the operation you wish to perform: " << endl;
                cout << "1 - Equality/Replace" << endl;
                cout << "2 - Add" << endl;
                cout << "3 - Multiply" << endl;
                cout << "4 - Evaluate" << endl;
                cout << "5 - Write to File" << endl;
                
                operation = getValidOperation();
                
                //carries out operation selected by user above
                switch (operation)
                {
                    case 1:
                        cout << "Setting polynomial 1 equal to polynomial 2 yields polynomial 1: " << endl;
                        p4 = p5;
                        cout << p4 << endl;
                        break;
                    case 2:
                        cout << "Adding polynomial 1 and polynomial 2 yields: " << endl;
                        p6 = p4 + p5;
                        cout << p6 << endl;
                        break;
                    case 3:
                        cout << "Multiplying polynomial 1 and polynomial 2 yields: " << endl;
                        p6 = p4 * p5;
                        cout << p6 << endl;
                        break;
                    case 4:
                        cout << "Enter a value for evaluation: " << endl;
                        x = getValidInt();
                        cout << "Evaluating polynomial 1 with " << x << " yields: " << endl;
                        cout << p4.evalPoly(x) << endl;
                        break;
                    case 5:
                        cout << "The first polynomial was written to \"output.txt\""<< endl;
                        p4.writeToFile();
                }
                
                break;
            
            //if user chooses double, prompted to enter 2 double polynomials                 
            case 3:
                cout << "Input the first double term: " << endl;
                cin >> p7;
            
                cout << "Input the second double term: " << endl;
                cin >> p8;
                
                //user prompted to choose operation to perform on polynomials
                cout << "Select the operation you wish to perform: " << endl;
                cout << "1 - Equality/Replace" << endl;
                cout << "2 - Add" << endl;
                cout << "3 - Multiply" << endl;
                cout << "4 - Evaluate" << endl;
                cout << "5 - Write to File" << endl;
                
                operation = getValidOperation();
                
                //carries out operation selected by user above
                switch (operation)
                {
                    case 1:
                        cout << "Setting polynomial 1 equal to polynomial 2 yields polynomial 1: " << endl;
                        p7 = p8;
                        cout << p7 << endl;
                        break;
                    case 2:
                        cout << "Adding polynomial 1 and polynomial 2 yields: " << endl;
                        p9 = p7 + p8;
                        cout << p9 << endl;
                        break;
                    case 3:
                        cout << "Multiplying polynomial 1 and polynomial 2 yields: " << endl;
                        p9 = p7 * p8;
                        cout << p9 << endl;
                        break;
                    case 4:
                        cout << "Enter a value for evaluation: " << endl;
                        x = getValidInt();
                        cout << "Evaluating polynomial 1 with " << x << " yields: " << endl;
                        cout << p7.evalPoly(x) << endl;
                        break;
                    case 5:
                        cout << "The first polynomial was written to \"output.txt\""<< endl;
                        p7.writeToFile();
                }
            
                break;  
            
            //if user chooses complex, prompted to enter 2 complex polynomials                 
            case 4:
                cout << "Input the first complex term: " << endl;
                cin >> p10;
                
                cout << "Input the second complex term: " << endl;
                cin >> p11;
                
                //user prompted to choose operation to perform on polynomials
                cout << "Select the operation you wish to perform: " << endl;
                cout << "1 - Equality/Replace" << endl;
                cout << "2 - Add" << endl;
                cout << "3 - Multiply" << endl;
                cout << "4 - Evaluate" << endl;
                cout << "5 - Write to File" << endl;
                
                operation = getValidOperation();
                
                //carries out operation selected by user above
                switch (operation)
                {
                    case 1:
                        cout << "Setting polynomial 1 equal to polynomial 2 yields polynomial 1: " << endl;
                        p10 = p11;
                        cout << p10 << endl;
                        break;
                    case 2:
                        cout << "Adding polynomial 1 and polynomial 2 yields: " << endl;
                        p12 = p10 + p11;
                        cout << p12 << endl;
                        break;
                    case 3:
                        cout << "Multiplying polynomial 1 and polynomial 2 yields: " << endl;
                        p12 = p10 * p11;
                        cout << p12 << endl;
                        break;
                    case 4:
                        cout << "Enter a value for evaluation: " << endl;
                        x = getValidInt();
                        cout << "Evaluating polynomial 1 with " << x << " yields: " << endl;
                        x1 = p10.evalPoly(x);
                        cout << x1 << endl;
                        break;
                    case 5:
                        cout << "The first polynomial was written to \"output.txt\""<< endl;
                        p10.complexWriteToFile();
                }
            
                break; 
            
            //if user chooses Test Driver, Test Driver begins                 
            case 5:
                cout << "This is the Test Driver. It checks all functionality for all data types.  Enjoy!" << endl;
                cout << "For reference, number is " << number << " for ints, " << number2 << " for floats/doubles, ";
                cout << "and " << number3 << " for complex numbers." << endl << endl;
                
                //prompts user to enter integer polynomial
                cout << "Enter Polynomial 1 (int): " << endl;
                cin >> p1;
                
                cout << "Polynomial 1 is:" << endl;
                cout << p1;
                
                //prompts user to input another integer polynomial from a file
                cout << "Enter Polynomial 2 (int) from a file" << endl;
                bool worked = true;
                string inFileName;
                ifstream inStr;
                
                //gets valid filename for input
                do 
                {
                    cout << "Enter name of file to read from: ";
                    cin >> inFileName;
                    
                    inStr.open (inFileName.c_str());
                    if (inStr.fail())
                    {
                        cerr << "Error opening file. Try again." << endl;
                        inStr.clear();
                        inStr.ignore(80, '\n');
                        worked = false;
                    }
                    else 
                        worked = true;
                    
                } while (!worked);
                
                inStr >> p2;
                inStr.close();
                
                cout << "Polynomial 2 is: " << endl;
                cout << p2;
                
                //sets polynomial 1 equal to polynomial 2
                cout << "Setting Polynomial 1 equal to Polynomial 2 makes Polynomial 1: " << endl;
                p1 = p2;
                cout << p1;
                
                //sets polynomial 1 equal to constant
                cout << "Setting Polynomial 1 equal to 4 makes Polynomial 1: " << endl;
                p1 = 4;
                cout << p1;
                
                //re-enter polynomial 1
                cout << "Enter Polynomial 1 (int)" << endl;
                cin >> p1;
                
                cout << "Polynomial 1 is now:" << endl;
                cout << p1;
                
                //test overloaded plus operator 
                cout << "Adding Polynomial 1 and Polynomial 2 gives:" << endl;
                p3 = p1 + p2;
                cout << p3 << endl;
                
                cout << "Adding Polynomial 1 and number gives:" << endl;
                p3 = p1 + number;
                cout << p3 << endl;
                
                cout << "Adding number and Polynomial 2 gives:" << endl;
                p3 = number + p2;
                cout << p3 << endl;
                
                //test overloaded multiplication operator
                cout << "Multiplying Polynomial 1 and Polynomial 2 gives:" << endl;
                p3 = p1 * p2;
                cout << p3 << endl;
                
                cout << "Multiplying Polynomial 1 and number gives:" << endl;
                p3 = p1 * number;
                cout << p3 << endl;
                
                cout << "Multiplying number and Polynomial 2 gives:" << endl;
                p3 = number * p2;
                cout << p3 << endl;
                
                //test polynomial evaluation
                cout << "Enter a value for x" << endl;
                cin >> x;
                
                cout << "Evaluating Polynomial 1 with " << x << " gives " << p1.evalPoly (x) << endl;
                
                //test writing to a file 
                cout << "Writing Polynomial 3 to a file." << endl << endl;

                p3.writeToFile();
                
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                
                //prompts user to enter float polynomial
                cout << "Enter Polynomial 4 (float): " << endl;
                cin >> p4;
                
                cout << "Polynomial 4 is:" << endl;
                cout << p4;
                
                //prompts user to enter another float polynomial from a file
                cout << "Enter Polynomial 5 (float) from a file" << endl;
                
                //gets valid filename for input
                do 
                {
                    cout << "Enter name of file to read from: ";
                    cin >> inFileName;
                    
                    inStr.open (inFileName.c_str());
                    if (inStr.fail())
                    {
                        cerr << "Error opening file. Try again." << endl;
                        inStr.clear();
                        inStr.ignore(80, '\n');
                        worked = false;
                    }
                    else 
                        worked = true;
                    
                } while (!worked);
                
                inStr >> p5;
                inStr.close();
                
                cout << "Polynomial 5 is: " << endl;
                cout << p5;
                
                //sets polynomial 4 equal to polynomial 5
                cout << "Setting Polynomial 4 equal to Polynomial 5 makes Polynomial 4: " << endl;
                p4 = p5;
                cout << p4;
                
                //sets polynomial 4 equal to constant
                cout << "Setting Polynomial 4 equal to 3.3 makes Polynomial 4: " << endl;
                p4 = 3.3;
                cout << p4;
                
                //re-enter polynomial 4
                cout << "Enter Polynomial 4 (float)" << endl;
                cin >> p4;
                
                cout << "Polynomial 4 is now:" << endl;
                cout << p4;
                
                //test overloaded plus operator 
                cout << "Adding Polynomial 4 and Polynomial 5 gives:" << endl;
                p6 = p4 + p5;
                cout << p6 << endl;
                
                cout << "Adding Polynomial 4 and number gives:" << endl;
                p6 = p4 + number2;
                cout << p6 << endl;
                
                cout << "Adding number and Polynomial 5 gives:" << endl;
                p6 = number2 + p5;
                cout << p6 << endl;
                
                //test overloaded multiplication operator
                cout << "Multiplying Polynomial 4 and Polynomial 5 gives:" << endl;
                p6 = p4 * p5;
                cout << p6 << endl;
                
                cout << "Multiplying Polynomial 4 and number gives:" << endl;
                p6 = p4 * number2;
                cout << p6 << endl;
                
                cout << "Multiplying number and Polynomial 5 gives:" << endl;
                p6 = number2 * p5;
                cout << p6 << endl;
                
                //test polynomial evaluation
                cout << "Enter a value for x" << endl;
                cin >> x;
                
                cout << "Evaluating Polynomial 4 with " << x << " gives " << p4.evalPoly (x) << endl;
                
                //test writing to a file 
                cout << "Writing Polynomial 6 to a file." << endl << endl;

                p6.writeToFile();
                
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------

                //prompts user to enter double polynomial
                cout << "Enter Polynomial 7 (double): " << endl;
                cin >> p7;
                
                cout << "Polynomial 7 is:" << endl;
                cout << p7;
                
                //prompts user to enter another double polynomial from a file
                cout << "Enter Polynomial 8 (double) from a file" << endl;
                
                //gets valid filename for input
                do 
                {
                    cout << "Enter name of file to read from: ";
                    cin >> inFileName;
                    
                    inStr.open (inFileName.c_str());
                    if (inStr.fail())
                    {
                        cerr << "Error opening file. Try again." << endl;
                        inStr.clear();
                        inStr.ignore(80, '\n');
                        worked = false;
                    }
                    else 
                        worked = true;
                    
                } while (!worked);
                
                inStr >> p8;
                inStr.close();
                
                cout << "Polynomial 8 is: " << endl;
                cout << p8;
                
                //sets polynomial 7 equal to polynomial 8
                cout << "Setting Polynomial 7 equal to Polynomial 8 makes Polynomial 7: " << endl;
                p7 = p8;
                cout << p7;
                
                //sets polynomial 7 equal to constant
                cout << "Setting Polynomial 7 equal to 6.7 makes Polynomial 7: " << endl;
                p7 = 6.7;
                cout << p7;
                
                //re-enter polynomial 7
                cout << "Enter Polynomial 7 (double)" << endl;
                cin >> p7;
                
                cout << "Polynomial 7 is now:" << endl;
                cout << p7;
                
                //test overloaded plus operator 
                cout << "Adding Polynomial 7 and Polynomial 8 gives:" << endl;
                p9 = p7 + p8;
                cout << p9 << endl;
                
                cout << "Adding Polynomial 7 and number gives:" << endl;
                p9 = p7 + number4;
                cout << p9 << endl;
                
                cout << "Adding number and Polynomial 8 gives:" << endl;
                p9 = number4 + p8;
                cout << p9 << endl;
                
                //test overloaded multiplication operator
                cout << "Multiplying Polynomial 7 and Polynomial 8 gives:" << endl;
                p9 = p7 * p8;
                cout << p9 << endl;
                
                cout << "Multiplying Polynomial 7 and number gives:" << endl;
                p9 = p7 * number4;
                cout << p9 << endl;
                
                cout << "Multiplying number and Polynomial 8 gives:" << endl;
                p9 = number4 * p8;
                cout << p9 << endl;
                
                //test polynomial evaluation
                cout << "Enter a value for x" << endl;
                cin >> x;
                
                cout << "Evaluating Polynomial 7 with " << x << " gives " << p4.evalPoly (x) << endl;
                
                //test writing to a file 
                cout << "Writing Polynomial 9 to a file." << endl << endl;
                
                p9.writeToFile();
                
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------
                //------------------------------------------------------------------------------------------------------------------                

                //prompts user to enter complex polynomial
                cout << "Enter Polynomial 10 (complex): " << endl;
                cin >> p10;
                
                cout << "Polynomial 10 is:" << endl;
                cout << p10;
                
                //prompts user to enter another complex polynomial from a file
                cout << "Enter Polynomial 11 (complex) from a file" << endl;
                
                //gets valid filename for input
                do 
                {
                    cout << "Enter name of file to read from: ";
                    cin >> inFileName;
                    
                    inStr.open (inFileName.c_str());
                    if (inStr.fail())
                    {
                        cerr << "Error opening file. Try again." << endl;
                        inStr.clear();
                        inStr.ignore(80, '\n');
                        worked = false;
                    }
                    else 
                        worked = true;
                    
                } while (!worked);
                
                inStr >> p11;
                inStr.close();
                
                cout << "Polynomial 11 is: " << endl;
                cout << p11;
                
                //sets polynomial 10 equal to polynomial 11
                cout << "Setting Polynomial 10 equal to Polynomial 11 makes Polynomial 10: " << endl;
                p10 = p11;
                cout << p10;
                
                //sets polynomial 10 equal to constant
                cout << "Setting Polynomial 10 equal to (4 + 3i) makes Polynomial 10: " << endl;
                p10 = Complex(4,3);
                cout << p10;
                
                //re-enter polynomial 10
                cout << "Enter Polynomial 10 (complex)" << endl;
                cin >> p10;
                
                cout << "Polynomial 10 is now:" << endl;
                cout << p10;
                
                //test overloaded plus operator 
                cout << "Adding Polynomial 10 and Polynomial 11 gives:" << endl;
                p12 = p10 + p11;
                cout << p12 << endl;
                
                cout << "Adding Polynomial 10 and number gives:" << endl;
                p12 = p10 + number3;
                cout << p12 << endl;
                
                cout << "Adding number and Polynomial 11 gives:" << endl;
                p12 = number3 + p11;
                cout << p12 << endl;
                
                //test overloaded multiplication operator
                cout << "Multiplying Polynomial 10 and Polynomial 11 gives:" << endl;
                p12 = p10 * p11;
                cout << p12 << endl;
                
                cout << "Multiplying Polynomial 10 and number gives:" << endl;
                p12 = p10 * number3;
                cout << p12 << endl;
                
                cout << "Multiplying number and Polynomial 11 gives:" << endl;
                p12 = number3 * p11;
                cout << p12 << endl;
                
                //test polynomial evaluation
                cout << "Enter a value for x" << endl;
                cin >> x;
                x1 = p10.evalPoly(x);
                
                cout << "Evaluating Polynomial 10 with " << x << " gives " << x1 << endl;
                
                //test writing to a file 
                cout << "Writing Polynomial 12 to a file." << endl << endl;

                p12.complexWriteToFile();
                
                break;
        }
        
        //asks user if they would like to perform any other operations
        //sets goAgain accordingly
        cout << "Would you like to perform another operation: " << endl;
        cout << "1 - Yes" << endl;
        cout << "2 - No" << endl;
        goAgain = getValidDecision();
        cout << endl;
    }
    
    //once user is done, outputs thank you and returns to Driver to end program
    cout << endl << "Thanks for using the Polynomial Machine!" << endl << endl;
    
    return;
}