Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java Programming Question. Part A is completed, and I understand how to write a menu program, but for Part B, how do I input a

Java Programming Question.

image text in transcribed

image text in transcribed

image text in transcribed

Part A is completed, and I understand how to write a menu program, but for Part B, how do I input a second polynomial? Code for part A is below.

import java.util.Scanner; public class PartA { public static void main (String [] args) { int deg,coeff; double xval, seg, sum = 0.0; Scanner sc = new Scanner (System.in); System.out.println("Enter the degree of the polynomial"); //Degree input deg = sc.nextInt(); System.out.println("Enter the value of x to evaluate the polynomial at"); //x value input xval = sc.nextInt(); for (int i = 0; i a) Polynomials are equations like the following: 24 35+21x + 9x + 7x + 10x which has one variable (x) and is a summation of many (we'll call) segments. Each segment includes a coefficient and an exponent. For every polynomial, the degree is defined as the highest exponent of any segiment. So for the above polynomial, the degree is 5. Note that for each exponent from 0 to degree (in this case 5), there is a segment, even though there is no segment that appears in the polynomial with an exponent of 3, there really is (we just say it has a coefficient of O, since 0 times anything is 0). In addition, for each exponent i (where i is from 0 to the degree), there is at most one segment with such an exponent (if there were multiple, we could simply combine them). Frequently, we like to evaluate polynomials at specific values ofx. That is, given the polynomial above, we'd like to know what the polynomial equals when, say, x=3. In the above example, the polynomial equals 3176 when x-3, since 35 +21(3) + 9(9) + 0(27) +7(81) + 10(243) = 3176 a) Polynomials are equations like the following: 24 35+21x + 9x + 7x + 10x which has one variable (x) and is a summation of many (we'll call) segments. Each segment includes a coefficient and an exponent. For every polynomial, the degree is defined as the highest exponent of any segiment. So for the above polynomial, the degree is 5. Note that for each exponent from 0 to degree (in this case 5), there is a segment, even though there is no segment that appears in the polynomial with an exponent of 3, there really is (we just say it has a coefficient of O, since 0 times anything is 0). In addition, for each exponent i (where i is from 0 to the degree), there is at most one segment with such an exponent (if there were multiple, we could simply combine them). Frequently, we like to evaluate polynomials at specific values ofx. That is, given the polynomial above, we'd like to know what the polynomial equals when, say, x=3. In the above example, the polynomial equals 3176 when x-3, since 35 +21(3) + 9(9) + 0(27) +7(81) + 10(243) = 3176

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions