#include <iostream>
#include <iomanip>
using namespace std;
//global constants
const int SIZE = 12;
//function prototypes
bool getAverageRainFall(double rain[SIZE]);
bool getExactRainFall(double rain[SIZE]);
void displayResults(const double actual[SIZE], const double average[SIZE]);
void printMonth(int month);
// PRECONDITION: month holds an integer 1-12
// POSTCONDITION: the corresponding month (Jan, Feb, ..., Dec) has been
// printed to the standard output.
int main()
{
double rainfall[SIZE];
double averages[SIZE];
getAverageRainFall(averages);
getExactRainFall(rainfall);
displayResults(rainfall, averages);
return 0;
}
bool getAverageRainFall(double rain[SIZE])
{
for(int x=0; x<SIZE; x++)
{
cout << "Enter the average rainfall: ";
<< printMonth(x);
cin >> rain[x];
}
}
bool getExactRainFall(double rain[SIZE])
{
for(int x=0; x<SIZE; x++)
{
cout << "Enter the actual rainfall: ";
<< printMonth(x);
cin >> rain[x];
}
}
void displayResults(const double actual[SIZE], const double average[SIZE])
{
double difference;
difference = actual - average;
cout << "Month Actual Average Difference";
for(int n=0; n<SIZE; n++)
{
cout << setw(7) << printMonth(n) << setw(8) << actual << setw(9) << average << setw(10)
<< difference;
}
}
void printMonth(int month)
{
cout.width(8);
switch(month)
{
case 0:
cout << "Jan";
break;
case 1:
cout << "Feb";
break;
case 2:
cout << "March";
break;
case 3:
cout << "April";
break;
case 4:
cout << "May";
break;
case 5:
cout << "June";
break;
case 6:
cout << "July";
break;
case 7:
cout << "Aug";
break;
case 8:
cout << "Sept";
break;
case 9:
cout << "Oct";
break;
case 10:
cout << "Nov";
break;
case 11:
cout << "Dec";
break;
}
}
here is my code can you help me fix my errors
Line 42
Error parse error before `<<' token
Line 53
Error parse error before `<<' token
line 67
error no match for `std::basic_ostream<char, std::char_traits<char> >& << void' operator/usr/local/include/c++/3.3/bits/ostream.tcc:63: error: 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/include/c++/3.3/bits/ostream.tcc:85: error: 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/include/c++/3.3/bits/ostream.tcc:107: error: 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>]/usr/local/include/c++/3.3/bits/ostream.tcc:179: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:216: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:154: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:178: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:189: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:193: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:204: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:242: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:280: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:306: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:219: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:331: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:356: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:128: error: std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_streambuf<_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:436: error: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:508: error: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char) [with _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:447: error: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char) [with _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:452: error: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char) [with _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:580: error: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/bits/ostream.tcc:630: error: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*) [with _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:486: error: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*) [with _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/ostream:491: error: std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*) [with _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/iomanip:82: error: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Resetiosflags) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/iomanip:116: error: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Setiosflags) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/iomanip:154: error: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Setbase) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/iomanip:227: error: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Setprecision) [with _CharT = char, _Traits = std::char_traits<char>]/usr/local/include/c++/3.3/iomanip:261: error: std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, std::_Setw) [with _CharT = char, _Traits = std::char_traits<char>]
moods125 0 Light Poster
mrnutty 761 Senior Poster
moods125 0 Light Poster
gastonci 0 Light Poster
moods125 0 Light Poster
moods125 0 Light Poster
gastonci 0 Light Poster
moods125 0 Light Poster
moods125 0 Light Poster
gastonci 0 Light Poster
moods125 0 Light Poster
gastonci 0 Light Poster
moods125 0 Light Poster
moods125 0 Light Poster
gastonci 0 Light Poster
gastonci 0 Light Poster
moods125 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.