JonStap

5 Reputation

One Badge

3 years, 243 days

MaplePrimes Activity


These are questions asked by JonStap

For bonus in my one class, we are required to change the code in a program to have it produce another row when running Neville's Method. We need to, after it runs initially, have it ask "Run another time? Y/N" and type 'Y' or 'N' for Yes or No. If No, it ends the program. If yes, we need to have it input another x(i) and f(x(i)) without having to input all the other data points again. Here is what I have so far (this is just the additional part we have to add, not the whole code):

 print(`Do you want another point? Type Y or N.`):
  J := scanf(` %c`)[1]:print(`Entry = `):print(J):
  if J = "Y" or J="y" then
  AGAIN := "Y":
  AGAIN = "Y" or AGAIN = "y":
        OUP := default:
      fprintf(OUP, `NEVILLE'S METHOD\n `):
       fprintf(OUP, `Table for P evaluated at X = %12.8f , follows: \n`, X):
       fprintf(OUP, `Entries are XX(I), Q(I,0), ..., Q(I,I) `):
       fprintf(OUP, `for each I = 0, ..., N where N = %3d\n\n`, N):
       for I1 from 0 to N+1 do
         fprintf(OUP, `%11.8f `, XX[I1]):
         for J from 0 to I1 do
           fprintf(OUP, `%11.8f `, Q[I1,J]):
         od:
         fprintf(OUP, `\n`):
        od:
    if J="Y" or J="y" then
         AGAIN := Y:
             if AGAIN = Y or AGAIN = y then
                 #N=N+1:
                  if N > 0 then
                  OK := TRUE:
                 for I1 from N to N+1 do
                        print(`Input X(i) and F(X(i)) for i = `):print(I1):
                        print(`separated by a space `):
                       XX[I1] := scanf(`%f`)[1]:
                       Q[I1,0] := scanf(`%f`)[1]:print(`Entries are`):print(XX[I1],Q[I1,0]):
                  od:
                else
                  print(`Number must be a positive integer `):
               fi:


            else
                AGAIN := No:     
         fi:
         fi:
    else
        print(`Ok thanks`):
 fi:

Not sure what I am doing wrong and any help is appreciated. Thanks.

Page 1 of 1