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

Write a program using Microsoft Visual Studios with three functions. The main fu

ID: 3677755 • Letter: W

Question

Write a program using Microsoft Visual Studios with three functions. The main function will just define and initialize the variables, prompt the user for data values and call the user functions. All the work will be done by the user functions. In the main function, define three double arrays of 40 elements each and initialize the arrays to zero.

The main function should prompt the user to enter the amplitude (Amp), frequency (freq) and phase of a cosine function. Read in the data and call user function #1. Then call function three and print the filled array to the screen. Limit the frequency between 0 to 10, and the amplitude between 1.0 and 2.0. No need to error check.

Prompt the user to enter in the amplitude of the random noise. Limit the value between 0.1 and 1.0. Read in the value and call user function #2. Then call function three and print the filled array to the screen.

Fill the third array with the sum of the values from the first and second arrays. Then call function #3 and print the third array to the screen. Do with a low noise and high noise amplitude. Look at the effects of noise on the sinusoid.

z[i] = x[i] + n[i]

Function #3: Graphically print the array to the screen. The function will be passed an array and its size and return nothing. Multiple each array element by 10, take the absolute value, type cast it to an int and print out that many ‘*’ asterisks to the screen. Repeat for all the passed array values. You should see a graph (absolute value) of the function, down the page, showing the function shape.

Explanation / Answer

//The required solution is as below

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AmpGraphDisplay
{
class Program
{
static void Main(string[] args)
{
var amps = new double[40];
amps.Initialize();

var freqs = new double[40];
freqs.Initialize();

var phases = new double[40];
phases.Initialize();
}

public static void Func_1(double[] items, InputTypes type)
{
int counter = 0;
for(int index = 0; index< items.Length; index++)
{
Console.WriteLine("Enter number...");
  
switch(type)
{
case InputTypes.Amp:
var num = Convert.ToDouble(Console.ReadLine());
if (num > 1.0 && num < 2.0)
{
items[counter++] = num;
}
break;

case InputTypes.Frequency:
var num = Convert.ToInt32(Console.ReadLine());
if(num > 0 && num < 10)
{
items[counter++] = num;
}
break;
}
  
}

Func_3(items, counter);
}

/// <summary>
/// Not able to understand the exact question
/// </summary>
public static void Func_2()
{

}

public static void Func_3(double[] items, int size)
{
for (int index = 0; index < size; index++ )
{
var val = Convert.ToInt32( items[index] * 10);
for (int cnt = 0; cnt < val; cnt++ )
{
Console.WriteLine("*");
}
}
}

private static enum InputTypes
{
Frequency,
Amp,
Phase
}
}


}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote