sounds like homework :)
-----Original Message----- From: Jeff O'Connell To: [EMAIL PROTECTED] Sent: 5/14/2002 3:00 PM Subject: How do I??? I'm trying to figure out how to do the following in Perl. Can anyone help me? Problem: Design and implement a perl program that will evaluate a polynomial expression of arbitrary degree for a given value of x. The program's user interface should look like the following: 1) prompt user for a non-negative integer that represents the degree of the polynomial expression i.e. print "Enter a non-negative integer"; chomp ($degree = <STDIN>); if the user enters 0, the program quits. if the user types in any other non-negative number, this input will determine the degree of the polynomial expression. Example: user enters 5, the polynomial expression will look like this: y(x4) + y(x3) + y(x2) + y(x1) + y (where y = coefficient and x will be a variable to be entered by the user in a later step) if the user enters 4, the polynomial expression will look like this: y(x3) + y(x2) + y(x1) + y if the user enters 3, the polynomial expression will look like this: y(x2) + y(x1) + y and so on.... 2) Based on the degree of the polynomial, now the user is prompted for the coefficients (I know I need to create an array here, but I'm not sure how?) i.e. if the user enters 5 in #1 above ($degree = 5), then the user will be prompted to enter in 5 coefficients (i.e. y) i.e. print "Enter the $degree coefficients'; (Here's where I don't know how to create the array. I have to grap the 5 ($degree) inputs and assign them to the array in order) is this even close???? $i = 0; @coefficients = while $i <= $degree - 1 @coefficients[$i] = <STDIN>; after the 5 coefficients have been entered by the user, the polynomial expression will look something like this (where @coefficients is the array holding the five values inputed by the user); coefficient[0](x4) + coefficient[1](x3) + coefficient[2](x2) + coefficient[3](x1) + y Somehow I also need to calculate the exponent based on the arbitrary degree entered by the user in step #1 above too??????? the first part of the polynomial expression should look like this: coefficient[0](x4) - How do I dynamically write the exponent based on $degree variable? 3) Now I need to prompt the user for the value of "X" to finish the polynomial expression i.e. print "Enter the value of X"; chomp ($x = <STDIN>); 4) Now I need to display the polynomial expression If $degree = 5 $x = 2 and @coefficients = (6,7,8,9.10), where the 6,7,8,9,10 values were inputted by the user in step#2 above, then the expression should look like this: 6(24) + 7(23) + 8(22) + 9(21) + 10 5) Now I need to calculate the expression $answer = 6(24) + 7(23) + 8(22) + 9(21) + 10 print "The polynomial expression value is : $answer"; Any help you could provide to me would be greatly appreciated. Thank You. Jeff O'Connell -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] "The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from all computers."