Question: 6.15 Lab 9 - Sum Series Complete the following program by writing the method named calcSum described as follows. The method should compute the sum

6.15 Lab 9 - Sum Series

Complete the following program by writing the method named calcSum described as follows. The method should compute the sum of the series 1/2 + 2/3 + 3/4 + + n/(n + 1) given the number of terms n and have the following signature:

static double calcSum(int n)

Here are 4 sample runs:

Enter the number of terms: 1 The resulting sum is 0.5000. Enter the number of terms: 2 The resulting sum is 1.1667. Enter the number of terms: 10 The resulting sum is 7.9801. Enter the number of terms: 1000 The resulting sum is 993.5135.

CODE;

import java.util.Scanner;

public class Lab9a {

public static void main(String[] args) {

System.out.print("Enter the number of terms: ");

Scanner input=new Scanner(System.in);

int n=input.nextInt();

input.close();

System.out.printf("The resulting sum is %.4f.%n",calcSum(n));

}//end main

//Write the method calcSum below this line. Do not modify method main.

}//end class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!