Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need help creating java program ************************************************

ID: 3847422 • Letter: N

Question

need help creating java program

*************************************************************

java program needs to pass the following test

*************************************************************

   public static void main(String[] args) {

double[] frequencies = {110.0, 110.0*1.224, 110.0*1.224*1.224};

       ArrayList<Chord> risingChords = Final.createRisingChordList(0.2, frequencies, 10);

       for (Chord risingChord: risingChords) {

           StdOut.println("Playing: " + risingChord);

           risingChord.play();

       }

       StdOut.println();

}

***********************************************

Chord class created in a previous assignment

***********************************************

import java.util.*;

import stdlib.*;

public class Chord {

   private double duration, frequencies[];

   public String toString() {

      return "[" + duration + ": "+ Arrays.toString(frequencies) + "]";}

   public Chord(double duration, double[] frequencies) {

   this.duration = duration;

   this.frequencies = frequencies;}

     

   public void play() {

   playChord(duration, frequencies);}

  

private void playChord(double duration, double[] frequencies) {

   final int sliceCount = (int) (StdAudio.SAMPLE_RATE * duration);

   final double[] slices = new double[sliceCount+1];

   for (int i = 0; i <= sliceCount; i++) {

       double chord = 0.0;

       for (double frequency: frequencies) {

           chord += Math.sin(2 * Math.PI * i * frequency / StdAudio.SAMPLE_RATE);

       }

       slices[i] = chord/frequencies.length;

   }

   StdAudio.play(slices);}

}

Swan song Using the chord class you created in a previous assignment, define in the Final class a method with the signature public static ArrayList

Explanation / Answer

Hi,

I have heavily commented the code for deeper understanding. I was not able to check the main function because I don't have the library which you have used but It should work fine according to the logic. If you have any doubts, feel free to comment. Also please give a thumbs up if the answer helped.

//Code starts here

//Code ends here

Hope it helps.