Answer the question
In order to leave comments, you need to log in
How to make a polynomial method and refer to it?
Good afternoon.
There is a method.
Polynomial
3X^2 -8X + 4
I want to make a method that will take the x value and run it through the formula and return the result.
Looks like he did something. But how now to give the user the opportunity to access this function?
import java.util.Scanner;
public class Polinom
{
public static void main ( String[] args )
{
System.out.print("Введите число");
}
public double polinom(double x)
{
Scanner number = new Scanner(System.in);
x = number.nextDouble();
double resultat = 3*Math.pow(x, 2)-8*x+4;
resultat = Math.round(resultat);
System.out.println(resultat);
System.out.print("Функция сработала");
return resultat;
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question