Write a java program
Attachments:
Answers
Answered by
0
Java programming software: To compile and run Java program code you need to download JDK (Java Development Kit). ... Javac is the Java compiler which converts java code into bytecode. To run type: java main_method_class where main_method_class is the name of the class which defines "main" method.
Answered by
4
CODE :
import java.util.*;
class Sample
{
public void main(String Args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the limit");
int n=sc.nextInt();
double s=0.0;
double S=0.0;
for(int i=1;i<=n;i++)
{
s=s+i;
S=S+1/s;
}
System.out.println("Sum is "+S);
}
}
Hope it helps !
______________________________
Similar questions
English,
7 months ago
English,
7 months ago
Business Studies,
1 year ago
Physics,
1 year ago
History,
1 year ago