Answer the question
In order to leave comments, you need to log in
How to solve similar equation using java?
Hello.
How can you solve this equation using java?
Here is an example of how I tried to solve it, but I suspect that this is not true.
import java.util.Scanner;
public class MYClass {
public static void main(String []args){
int n,k;
Scanner sc = new Scanner(System.in);
System.out.println("Введите число N: ");
n=sc.nextInt();
System.out.println("Введите число K: ");
k=sc.nextInt();
for(int i=1;i<n;i++){
for(int j=1;j<k;j++){
System.out.println((j+3)/(i+Math.pow(j,2)));
}
}
}
}
Answer the question
In order to leave comments, you need to log in
Instead of displaying to the screen, you need to store the value in a variable and add a new value to it on each iteration of the loop
double sum = 0;
for(int i=1;i<n;i++){
for(int j=1;j<k;j++){
double divider = i+Math.pow(j,2);
if( divider != 0 )
sum+=(j+3)/divider;
else
// обработать ошибку
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question