I get an error: "The local variable y may not have been initialized." How would I initialize it?
Code:
package numberdoub;
import java.util.*;
public class Numberdoub
{
static double redouble (double x, double y){
//equation
while (y < 1000){
y = 2*x;}
return x;
}
public static void main(String[] args) {
//defines variable
double x, y;
Scanner sc = new Scanner (System.in);
//user input
System.out.print("x = ");
x = sc.nextDouble();
//answers
System.out.println("The answer is: " + y);
}
}