I need help with c++ homework for school.

I need help with homework due tomorrow morning at 7 am. This is my first coding class I have ever taken and it seems way above my head. I will post everything my teacher has given us below.

Code below is what I have tried to do far and probably not right
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
 #include <iostream>
using namespace std;

double GetMean(double Signal[], int Length);
void GetMinMax(double Signal[], int Length, double &Min, double &Max);

int main()
{

    const int CAPACITY = 9999;
    double Signal[CAPACITY];
    int Length = 0;

    double Val;
    while ( cin >> Val )
    {

          if ( Length == CAPACITY )
          {
             cout << "Too many values" << endl;
             return 0;
          }

          A[Length++] = Val;
    }

}

double GetMean(double, Signal[], int Length);
{



}
void GetMinMax(double Signal[], int Length, double &Min, double &Max);
{



}

Introduction
A compander is a device that makes an audio signal more uniform prior to transmission or playback.

If the signal is too large the compander compresses it and if too small, the compander it expands it, hence the name compander = compressor-expander.

We will use arrays to build a digital compander that will compand an audio signal into the dynamic range between -1.0 and 1.0.

The effect of our digital compander will be what is shown in the figure below.
Compander Image

We note that the raw signal at the top is very small and also has a vertical shift. The compander centers the signal at zero and expands (amplifies) it into the -1.0 to 1.0 range.

The bottom raw signal has very large amplitude. The compander in this case compresses the signal into the -1.0 to 1.0 range.

The compander formula we will use works as follows.

Suppose that Mean is the mean value of the raw signal, Max is the maximum value in the raw signal, and Min in the minimum value in the the raw signal.
Then we define a scale factor ScaleFactor as the larger of the two values
Max - Mean and Mean - Min.
Then for each sample xi in the raw signal we create the companded sample by the formula: (xi -Mean) / ScaleFactor.
Specifications

Write a function
void GetMinMax(double Signal[],
int Length, // the length of the array Signal[]
double &Min, // the min value found in Signal[]
double &Max) // the max value found in Signal[]

that accepts an array of doubles as a parameter and passes back the minimum and maximum values found in the array.

Write a function
double GetMean(double Signal[], int Length)

that returns the mean of the array Signal[].

Your program should
Allow successive values of the signal to be entered from the keyboard separated by line feeds and ending the list with Ctrl-D
Output the companded signal showing each companded sample on its own line (See output below).
The internal array to store the entered values should have a capacity of 10,000.
If too many values are entered, then the program should output the message "Input too long" and do nothing further.


Underlined numbers is user input
Direct Keyboard Input: Your program should produce exactly the same output as what is shown below.
$ ./a.out
3
4
5

(Ctrl-D)
-1.000
0.000
1.000
$ ./a.out
-0.03
-0.02
-0.01

(Ctrl-D)
-1.000
0.000
1.000
$./a.out
212
110
57
22
3
-5
-10
-17
-22.2

(Ctrl-D)
1.000
0.411
0.105
-0.097
-0.207
-0.253
-0.282
-0.323
-0.353






Thank you for any help you give!
Last edited on
I need help with homework due tomorrow morning at 7 am. This is my first coding class I have ever taken and it seems way above my head.

I wonder what is your problem?
Is it your code, or the given code?
Last edited on
the code I gave was what I have so far. I'm not sure if it is right or not.
And what the program is suppose to do is bold under specifications.
Last edited on
The code I gave was what I have so far. I'm not sure if it is right or not.

You should know it for yourself, don't ask us.
If you ask me, you should fix this problem first.
The function GetMean() is incomplete.
Last edited on
The problem is that I'm very new to c++ and not really sure what I'm doing so I need a lot of help.
PresidentSquid what is the mean for: 3, 5, 9? How would you go about finding the mean? Write it down in steps if you have to. After you figure that out transfer it to your program under GetMean. Remember to correct it so it will work with the project.
If you need that much help you need a tutor. Ask your teacher to help find you one.

When you come here we don't want to read your entire book or homework assignment. Try to do it yourself, get as far as you can and then post your question to get you past the part your stuck on or have a question about.

Don't expect anyone to write the code for you. It might happen but It's not our homework.
The harder you try, the more you comment your code, the more you understand what you have written the better help your going to get. Also the better you phrase your question the better results. Think garbage in garbage out...
Topic archived. No new replies allowed.