Hi. Im working on a problem and Im having trouble with it.
In the class Mymath, write a method called lab51 that reads three doubles a, b and c followed by one non-negative integer k, and prints the values of the function y = ax2 + bx + c
for the first k values. Validate the k value.
Your program should functions as follows:
Enter a: 1.5
Enter b: 2.5
Enter c: 3.5
Enter k: 4
x y= 1.5x^2 + 2.5x + 3.5
1 7.5
2 14.5
3 24.5
4 37.5
Heres my input:
import java.util.Scanner;
public class MyMath {
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
double a;
System.out.println("Enter a");
a = input.nextDouble();
double b;
System.out.println("Enter b");
b = input.nextDouble();
double c;
System.out.println("Enter c");
c = input.nextDouble();
int k;
System.out.println("Enter k");
k = input.nextInt();
double x;
x = input.nextInt();
double y;
y = (a * x * x) + (b * x) + c;
System.out.println("y");
}
}
Im having trouble displaying the output, and Im confused what my professor means by "validate k" and also having trouble with where k belongs. PLEASE HELP!