Question: Can I get help with this java project. I have created the following code but I get errors. This is the code package project1; import

Can I get help with this java project. I have created the following code but I get errors. This is the code

package project1;

import java.util.Scanner;

public class harmonicNumber { public static harmonicSum(int h){ if(h == 1){ return 1.0; } else{ return (1.0 / h) + harmonicSum(h - 1); } } public static void main(String[] args){ Scanner scn = new Scanner(System.in); System.out.println(" Enter A Number "); int n = scn.nextInt(); double hsum = harmonicSum(n); System.out.println(" Harmonic sum " + hsum); } } Can I get help with this java project. I have created the

2. The n" Harmonic number is the sum of the reciprocals of the first n natural numbers Write a recursive method and accompanying main method to compute the nh Harmonic number (5 points)

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!