State the name of method, method header and method declaration in the program. Briefly explain what the method do 2. Given the following program: 1 import java.util.*; 2 3 public class Harmonic { 40...


State the name of method, method header and method declaration in the program. Briefly explain what the method do


2. Given the following program:<br>1 import java.util.*;<br>2<br>3 public class Harmonic {<br>40<br>public static double harmonic (int n) {<br>double sum =<br>0.0;<br>for (int i = 1; i <= n; i++) {<br>sum += 1.0/ i;<br>}<br>6<br>7<br>8<br>return sum;<br>10<br>11<br>120<br>}<br>public static void main(String[] args) {<br>Scanner sc = new Scanner(System.in);<br>int N = sc.nextInt();<br>for (int i = 0; i < N; i++) {<br>13<br>14<br>15<br>16<br>17<br>18<br>19<br>20<br>21 }<br>%D<br>int arg = sc.nextInt();<br>double value = harmonic(arg);<br>System.out.println(value);<br>%3D<br>}<br>}<br>Figure 4: Program 6.4<br>a) State the name of method, method header and method declaration in the program. Briefly<br>explain what the method do:<br>

Extracted text: 2. Given the following program: 1 import java.util.*; 2 3 public class Harmonic { 40 public static double harmonic (int n) { double sum = 0.0; for (int i = 1; i <= n;="" i++)="" {="" sum="" +="1.0/" i;="" }="" 6="" 7="" 8="" return="" sum;="" 10="" 11="" 120="" }="" public="" static="" void="" main(string[]="" args)="" {="" scanner="" sc="new" scanner(system.in);="" int="" n="sc.nextInt();" for="" (int="" i="0;" i="">< n;="" i++)="" {="" 13="" 14="" 15="" 16="" 17="" 18="" 19="" 20="" 21="" }="" %d="" int="" arg="sc.nextInt();" double="" value="harmonic(arg);" system.out.println(value);="" %3d="" }="" }="" figure="" 4:="" program="" 6.4="" a)="" state="" the="" name="" of="" method,="" method="" header="" and="" method="" declaration="" in="" the="" program.="" briefly="" explain="" what="" the="" method="">

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here