Computer Science, asked by creatingmyselfrn, 10 months ago

wap in java to input n and find the sum of 1 + (1/2)^2 + (1/3)^2 + (1/n)^2.
all inputs using scanner class.

Answers

Answered by Anonymous
1

Answer:

import java.util.Scanner;

public class Sum

{

public static void main(String arts[])

{

double sum;

Scanner in = new Scanner(System.in);

System.out.println("Enter the value of n");

int n = in.nextInt();

sum=1+((1/2)*(1/2))+((1/3)*(1/3))+((1/n)*(1/n));

System.out.println("Solution of Expression :"+sum);

}

}

Hope this helps you.

PLEASE MARK IT AS THE BRANLIEST !!!

Similar questions