Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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); } }
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started