Answered step by step
Verified Expert Solution
Link Copied!

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); } } image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transactions On Large Scale Data And Knowledge Centered Systems Xxviii Special Issue On Database And Expert Systems Applications Lncs 9940

Authors: Abdelkader Hameurlain ,Josef Kung ,Roland Wagner ,Qimin Chen

1st Edition

3662534541, 978-3662534540

More Books

Students also viewed these Databases questions

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago

Question

Compute the derivative f(x)=(x-a)(x-b)

Answered: 1 week ago