I am having a problem with a program. I have to create a program with about 8 different functions. Which reads in votes, finds the max, the min, prints the votes, prints the max prints the mid, finds the normalization, outputs how many are below .25 and above .75 and prints the normalization. I've got the program typed but I'm coming up with alot of errors when I compile. Can anyone help me out with these problems?
Thanks, SportsFilmer
#include <iostream>
#include <iomanip>
using namespace std;
void readData (double []);
void print1 (double []);
int findmax (double []);
int findmin (double []);
void print2 (double [], int, int);
void norm (double [], int, int);
void normquart (double [], int, int);
void print3 (double []);
int main ()
{
int maxloc, minloc, range, bottom = 0, top = 0;
double votes [50], min = votes[minloc], max =
votes[maxloc];
readData (votes);
print1 (votes);
maxloc=findmax (votes);
minloc=findmin (votes);
print2 (votes, maxloc, minloc);
norm (votes, maxloc, minloc);
normquart (votes, bottom, top);
print3 (votes);
return 0;
}
void readData (double votes [])
{
for (int i=0; i<50; i++)
{
cin>> votes [i];
}
}
void print1 (double votes [])
{
for (int i=0; i<50; i++)
{
cout<< votes[i] <<endl;
}
}
int findmax (double votes [])
{
int max=0;
for (int i=1; i<50; i++)
{
if (votes [i]>votes[max])
{
max=i;
}
}
return max;
}
int findmin (double votes [])
{
int min=0;
for (int i=1; i<50; i++)
{
if (votes [i]<votes[min])
{
min=i;
}
}
return min;
}
void print2 (double votes[], int maxloc, int minloc)
{
cout<< "The maximum value is" <<votes[maxloc];
cout<< "The location is" <<max <<endl;
cout<< "The minimum value is" <<votes[minloc];
cout<< "The location is" <<min <<endl;
}
void norm (double votes[], int maxloc, int minloc)
{
max=votes[maxloc];
min=votes[minloc];
range = max-min;
{
for (i=0;i<50;i++)
{
vote[i]=(vote[i]-min)/range;
}
}
}
void normquart (double votes[], int bottom, int top)
{
for (i=0; i<50; i++)
{
{
if (vote[i]=<0.25)
bottom++;
}
{
if
else (vote [i]=>0.75)
top++;
}
}
cout<<"The number of nromalized values in the bottom is: " <<bottom;
cout<<"The number of nromalized values in the top is: " <<top;
}
void print 3 (double votes[])
{
for (i=0; i<50; i++)
{
cout<<"This is a record of the votes normalized: " << votes[i];
}
}
Here are the errors I'm getting:
p7a.cpp:18: warning: unused variable 'min'
p7a.cpp:18: warning: unused variable 'max'
p7a.cpp: In function 'void print2(double*, int, int)':
p7a.cpp:81: error: no match for 'operator<<' in 'std::operator<< [with _Traits = std::char_traits<char>](((std::basic_ostream<char, std::char_traits<char> >&)(& std::cout)), ((const char*)"The location is")) << std::max'
/usr/local/lib/gcc/sparc64-sun-solaris2.10/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:67: note: candidates are: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>& (*)(std::basic_ostream<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/local/lib/gcc/sparc64-sun-solaris2.10/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:78: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ios<_CharT, _Traits>& (*)(std::basic_ios<_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits<char>]
/usr/local/lib/gcc/sparc64-sun-solaris2.10/4.1.1/../../../../include/c++/4.1.1/bits/ostream.tcc:90: note: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits<char>]
p7a.cpp:90: error: invalid operands of types '<unresolved overloaded function type>' and '<unresolved overloaded function type>' to binary 'operator-'
p7a.cpp:92: error: 'i' was not declared in this scope
p7a.cpp:94: error: 'vote' was not declared in this scope
p7a.cpp:94: error: invalid operands of types '<unresolved overloaded function type>' and 'int' to binary 'operator/'
p7a.cpp: At global scope:
p7a.cpp:98: error: 'top' has not been declared
p7a.cpp: In function 'void normquart(double*, int, int)':
p7a.cpp:100: error: declaration of 'int bottom' shadows a parameter
p7a.cpp:101: error: 'i' was not declared in this scope
p7a.cpp:103: error: 'vote' was not declared in this scope
p7a.cpp:103: error: expected primary-expression before '<' token
p7a.cpp:106: error: expected `(' before 'else'
p7a.cpp: At global scope:
p7a.cpp:114: error: expected initializer before numeric constant