Flle Edit view Code Bulld RU LIFT Help Wéék 2 - GeherallzedHarmoniC.java O Project v GeneralizedHarmonic.java X v Week 2 C:\Users\Tyler_0qxkiq5\Desktop\Week 2 7 int n = Integer.parseInt(args[0]); src...


My code keeps giving me an answer of 1.  If i set the values manually it gives a correct answer so the math portion is correct but when i add a command line it always gives value of 1 please help


Flle<br>Edit view Code<br>Bulld<br>RU<br>LIFT<br>Help<br>Wéék 2 - GeherallzedHarmoniC.java<br>O Project v<br>GeneralizedHarmonic.java X<br>v Week 2 C:\Users\Tyler_0qxkiq5\Desktop\Week 2<br>7<br>int n = Integer.parseInt(args[0]);<br>src<br>8<br>int r =<br>Integer.parseInt(args[1]);<br>GeneralizedHarmonic<br>nli External Libraries<br>9<br>Scratches and Consoles<br>10<br>//Looping<br>11<br>for (int i = 1; i <= n; i++) {<br>12<br>//Computing the sum<br>13<br>sm += 1.0 /Math.pow(i,r);<br>14<br>}<br>15<br>// print the nth harmonic number<br>16<br>System.out.println(sum);<br>17<br>18<br>}<br>19<br>}<br>20<br>Run:<br>GeneralizedHarmonic X<br>

Extracted text: Flle Edit view Code Bulld RU LIFT Help Wéék 2 - GeherallzedHarmoniC.java O Project v GeneralizedHarmonic.java X v Week 2 C:\Users\Tyler_0qxkiq5\Desktop\Week 2 7 int n = Integer.parseInt(args[0]); src 8 int r = Integer.parseInt(args[1]); GeneralizedHarmonic nli External Libraries 9 Scratches and Consoles 10 //Looping 11 for (int i = 1; i <= n;="" i++)="" {="" 12="" computing="" the="" sum="" 13="" sm="" +="1.0" math.pow(i,r);="" 14="" }="" 15="" print="" the="" nth="" harmonic="" number="" 16="" system.out.println(sum);="" 17="" 18="" }="" 19="" }="" 20="" run:="" generalizedharmonic="" x="" "c:\program="" files\adopt0penjdk\jdk-11.0.11.9-hotspot\bin\java.exe"="" "-javaagent:c:\program="" files="" (x86)\jetbrains\intellij="" idea="" 1.0="" process="" finished="" with="" exit="" code="" 0="" |="" ig="" ri="">
CONDITIONALS<br>G LOOPS<br>LOOPS AND CONDITIONALS<br>FAQ O<br>Spec E<br>Project D<br>Submit co<br>1. Generalized harmonic numbers. Write a program GeneralizedHarmonic.java that takes two integer command-line arguments n and r and uses a for loop to compute<br>the n'h generalized harmonic number of order r, which is defined by the following formula:<br>1<br>1<br>1<br>H(n, r)<br>1
java GeneralizedHarmonic 1 1 1.0 ~/Desktop/loops> java GeneralizedHarmonic 2 1 1.5 ~/Desktop/loops> java GeneralizedHarmonic 3 1 1.8333333333333333 ~/Desktop/loops> java GeneralizedHarmonic 1 2 1.0 ~/Desktop/loops> java GeneralizedHarmonic 2 2 1.25 ~/Desktop/loops> java GeneralizedHarmonic 3 2 1.3611111111111112 Note: you may assume that n is a positive integer. "/>
Extracted text: CONDITIONALS G LOOPS LOOPS AND CONDITIONALS FAQ O Spec E Project D Submit co 1. Generalized harmonic numbers. Write a program GeneralizedHarmonic.java that takes two integer command-line arguments n and r and uses a for loop to compute the n'h generalized harmonic number of order r, which is defined by the following formula: 1 1 1 H(n, r) 1" 2" n" 1 For example, H(3, 2) 1² 49 - 1.361111. 36 1 22 32 ~/Desktop/loops> java GeneralizedHarmonic 1 1 1.0 ~/Desktop/loops> java GeneralizedHarmonic 2 1 1.5 ~/Desktop/loops> java GeneralizedHarmonic 3 1 1.8333333333333333 ~/Desktop/loops> java GeneralizedHarmonic 1 2 1.0 ~/Desktop/loops> java GeneralizedHarmonic 2 2 1.25 ~/Desktop/loops> java GeneralizedHarmonic 3 2 1.3611111111111112 Note: you may assume that n is a positive integer.
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here