Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Remainder Theorem
Author Message
randint

Posted: 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

Filename:  Remainder_Theorem.java
Filesize:  1.74 KB

Zren

Posted: 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

Posted: 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: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 3 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: