introduction to object oriented programming 6

A sinusoid or sine wave is a mathematical function of the form

𝑦(𝑡) = 𝐴 sin(2𝜋𝑓𝑡 + 𝑡0) + 𝑦0,

with four parameters:

  • 𝐴 denotes the amplitude of the sine wave (default value: 1).
  • 𝑓 denotes the frequency of the sine wave in Hz (default value: 1/2𝜋).
  • 𝑡0 denotes the amount of phase (horizontal) shift of the sine wave (default value: 0).
  • 𝑦0 denotes the y-offset or vertical shift of the sine wave (default value: 0).Create a class called Sinusoid with four double data fields representing the four parameters. Additionally, create the following:
  • No-argument constructor Sinusoid() that creates a sinusoid with the four default parameter values.
  • Constructor Sinusoid(double newAmplitude, double newFreq, double newPhase, double newYOffset) that creates a sinusoid with the user-specified parameter values.
  • Method double evalAt(double t) that evaluates the y value of the sinusoid at time t.
  • Method double[] evalAt(double[] tArray) that evaluates the y values of the sinusoids at thetimes in array tArray.
  • Method void printFunction() that prints the functional form of the sinusoid to the console with2 decimal places for each parameter, e.g. y(t) = 2.00sin(6.28t + 0.50) + 0.10 for the sinusoid with amplitude 2, frequency 1, phase 0.5, and y-offset 0.1.Submit your source code in a file named Sinusoid.java! Do not include a main() method in your submission!
 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp