Question
CS 254 Program 2 Harmonic Numbers The nth partial sum of the diverging harmonic series, is called the nth harmonic number. Write a program in
CS 254 Program 2 Harmonic Numbers The nth partial sum of the diverging harmonic series, is called the nth harmonic number. Write a program in Java or C that asks the user for n, and then computes the nth harmonic number in four ways: 1. Sum the terms from 1/1 up to 1/n. Use single precision variables (primitive type float) for the sum and each term. 2. Sum the terms from 1/n down to 1/1. Use single precision variables (primitive type float) for the sum and each term. 3. Sum the terms from 1/1 up to 1/n. Use double precision variables (primitive type double) for the sum and each term. 4. Sum the terms from 1/n down to 1/1. Use double precision variables (primitive type double for the sum and each term. Write out each of the four sums. For n large enough you will get a different answer for each of the four. Use an integer loop control variable for the counting loops. Type cast it to single or double when you add each term of the series to the partial sum. User interaction will look something like: Upper Limit --> 100 upward sum (float) = x.xxxx downward sum (float) = x.xxxx upward sum (double) = x.xxxx downward sum (double) = x.xxxx Turn in a source file of the program. Be sure that what you turn in is a source file, not a complete project. Use the "Add Attachments" button to do this. I know this answer is already posted to chegg study, but would it be possible to have it done in Java? Thanks :)
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