#include "polynomial.h"
#include
#include
void Display_Instructions();
int main()
{
LPPOLYNOMIAL main_polynomial, secondary_polynomial, result_polynomial;
int operation, result;
Display_Instructions();
main_polynomial = New_Polynomial();
result = Input_Polynomial(main_polynomial);
while (result == FAILURE)
{
printf("You did not input a valid polynomial.\n");
result = Input_Polynomial(main_polynomial);
}
do
{
Input_Operation(&operation);
if (operation != OPERATION_EXIT)
{
Input_Polynomial(secondary_polynomial);
result_polynomial = Perform_Operation(main_polynomial, secondary_polynomial, operation);
Delete_Polynomial(&secondary_polynomial);
Delete_Polynomial(&main_polynomial);
Simplify_Polynomial(result_polynomial);
Display_Polynomial(result_polynomial);
printf("\n");
main_polynomial = result_polynomial;
}
} while (operation != OPERATION_EXIT);
Delete_Polynomial(&main_polynomial);
return 0;
}
void Display_Instructions()
{
printf("--------------------- Brad Klingensmith ---------------------\n");
printf("How to input a polynomial:\n");
printf("\tEx: 3x^2 + y + 3xy + 1\n");
printf("\tEnter the polynomial just as it is written with the\n");
printf("\t\texception of using the ^ symbol to\n");
printf("\t\tspecify powers.\n");
printf("\tIf a coefficient or exponent is not specified, it is\n");
printf("\t\tassumed to be one: y is treated as 1y^1\n");
printf("\tMultiple variables can be used in a single term.\n");
printf("\t\tEx: xy is treated as x ");
putchar(0xB7);
printf(" y\n");
printf("\t\tAll variables must be single letters\n");
printf("\tNote that all spaces are removed before processing.\n");
printf("\t\tEx: 3 x ^ 7 is read as 3x^7\n");
printf("\nHow to input an operation:\n");
printf("\tTo add, type +, a, or add\n");
printf("\tTo multiply, type *, m, or mul\n");
printf("-------------------------------------------------------------\n");
}