I have the following program, and I want to print the appropriate return statement for the numbers given. I am currently getting the error "cannot find symbol variable result, lines 18 & 19"... how do I get it to work, though? I've tried a few different ways, and this is my current method:
import java.awt.Color;
import java.util.Scanner;
public class ReturnColor {
public static void main(String args[]) {
Scanner kboard = new Scanner(System.in);
System.out.println("Enter the amount of red:");
int r = kboard.nextInt();
System.out.println("Enter the amount of green:");
int g = kboard.nextInt();
System.out.println("Enter the amount of blue:");
int b = kboard.nextInt();
returnResult = bestMatch(r, g, b);
System.out.println(returnResult);
}
public static Color bestMatch(int r, int g, int b) {
if ((r > g) && (r > b))
return Color.RED;
if ((g > r) && (g > b))
return Color.GREEN;
if ((b > r) && (b > g))
return Color.BLUE;
if ((r == g) && (r > b))
return Color.YELLOW;
if ((r == b) && (r > g))
return Color.MAGENTA;
if ((b == g) && (b > r))
return Color.CYAN;
else
return Color.GRAY;
}
}