Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Remainder Theorem
Index -> Programming, Java -> Java Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
randint




PostPosted: Sat Oct 29, 2011 3:55 pm   Post subject: Remainder Theorem

The remainder theorem, known as P(x)/d(x), where P(x) is any polynomial, d(x) is a linear. When you use the the root of d(x) and "plug" it into P(x), you get the remainder of the function.


Remainder_Theorem.java
 Description:
This file uses the remainder theorem to get the remainder of the polynomial over another

Download
 Filename:  Remainder_Theorem.java
 Filesize:  1.74 KB
 Downloaded:  221 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Zren




PostPosted: Sat Oct 29, 2011 6:28 pm   Post subject: RE:Remainder Theorem

You might want to consider showing which coefficient your input is for.

Eg: 'Enter coefficient n (nx^3): '

~

Also, when a user's input is incorrect, you should not be continuing.

Java:

        try
        {
            degree = Integer.parseInt (br.readLine()) + 1;
        }
        catch (NumberFormatException n)
        {
            System.out.println ("You have not entered a valid integer!");
        }


You should either loop input until a valid input has been given, or you should be exiting your logic process when it happens.

code:

C:\Users\Admin\Desktop>java Remainder_Theorem
Enter the highest degree term: 0
Enter coefficient: a
You have not entered a valid number!
Enter the slope: a
You have not entered a valid number!
0.0x is a factor of this polynomial.


I'll also hint that since you're getting a double as input more than once, that you should consider writing a function to getInputDouble() that'll do the looping/error catching inside of that, and would return a valid number.
randint




PostPosted: Sun Oct 30, 2011 1:00 pm   Post subject: RE:Remainder Theorem

Yes, this is correct, in the newer version, I will add System.exit (0); in the catch blocks.
Display posts from previous:   
   Index -> Programming, Java -> Java Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: