Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. User Interface
  2. The program will start by printing a prompt message asking the user to enter a one-character command: e (evaluate), i (integrate), m (multiply), g (generate), q (quit).
  3. Enter a command (e,i,m,g,q):
  4. Depending on the command, the program will do one of the following. An example of each interaction is shown, with user input in bold. After each, the command prompt will appear again, until the user enters the quit command.
  5.  
  6. Evaluate
  7. The program will ask the user to input a polynomial, and then input a value for x to be evaluated. The resulting value is printed. The polynomial must be degree 4 or less when testing with the provided main function. The input value and the result may be integer or floating-point.
  8. EVALUATE
  9. Enter a polynomial f(x):
  10. x^3 – 7
  11. Enter x: 4
  12. f(4) = 57
  13.  
  14. Integrate
  15. The program will ask the user to input a polynomial, then enter the lower and upper limits of integration. The polynomial must be degree 4 or less. The limits may be integer or floating-point. The result of the integration is then printed.
  16. INTEGRATE
  17. Enter a polynomial f(x):
  18. x^3 – 7
  19. Enter lower limit: 0
  20. Enter upper limit: 1
  21. Integral of f(x) = -6.75
  22.  
  23. Multiply
  24. The program will ask the user to enter two polynomials, and will then print the polynomial product. Each polynomial must be degree 4 or less, which means the product will be degree 8 or less. For this example, the last line is what the program prints as the polynomial product.
  25. MULTIPLY
  26. Enter first polynomial f(x):
  27. x^3 – 7
  28. Enter second polynomial g(x):
  29. 3x^4 + 9x^2
  30. f(x) * g(x) = 3x^7 + 9x^5 – 21x^4 -63x^2
  31.  
  32. Generate
  33. The program will ask the user for the degree of polynomial, followed by each root (the appropriate number of roots depends on the degree the user provides). All inputs must be integers. The program then prints the generated polynomial (e.g. the last line in this example).
  34. GENERATE
  35. Enter the degree (<=4): 4
  36. Integer Root 1 = -2
  37. Integer Root 2 = 1
  38. Integer Root 3 = -16
  39. Integer Root 4 = 5
  40. f(x) = x^4 + 12x^3 – 71x^2 – 102x + 160
  41.  
  42. Quit
  43. The program ends.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement