I’ve got this equation that I want to solve with a java application.
It looks like this
y*n-1 = y*n-2 + 1035 + [(n-1)^2 + (n-3)] * y
y*n = y*n-1 + (n^2 * y)
So the user should input N and then the Java application should calculate how much Y is.
Is that somehow possible to do and if so, how?
Thanks in advance,
Michael.
EDIT:
Thanks to mprabhat, it looks like this right now but I’m still doing it wrong somehow..
public class equation
{
private static double solveFirstEquation(double n){
double y =0;
if(n > 0) {
y = ((n -1) + Math.pow( n , 2))/ n;
}
return y;
}
private static double solveSecondEquation(double n){
double y = 0;
if(n > 1) {
y = ((n-2)+ (Math.pow(n-1, 2) + n-3) + 1035)/(n-1);
}
return y;
}
public static void main(String args[])
{
System.out.println("How much is n?");
int n = 0;
n = Keyboard.readInt();
}
}
I tried to put the “void main String args” in the top but that wouldn’t let me run the application.
Something like this :
}