#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&ltchar, std::char_traits&ltchar> >& << void' operator/usr/local/include/c++/3.3/bits/ostream.tcc:63: error: candidates are: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(std::basic_ostream&lt_CharT, _Traits>&(*)(std::basic_ostream&lt_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:85: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(std::basic_ios&lt_CharT, _Traits>&(*)(std::basic_ios&lt_CharT, _Traits>&)) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:107: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(std::ios_base&(*)(std::ios_base&)) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:179: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(long int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:216: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:154: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(bool) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:178: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(short int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:189: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:193: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:204: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:242: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(long long int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:280: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:306: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(double) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:219: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(float) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:331: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(long double) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:356: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(const void*) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:128: error: std::basic_ostream&lt_CharT, _Traits>& std::basic_ostream&lt_CharT, _Traits>::operator<<(std::basic_streambuf&lt_CharT, _Traits>*) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:436: error: std::basic_ostream&lt_CharT, _Traits>& std::operator<<(std::basic_ostream&lt_CharT, _Traits>&, char) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:508: error: std::basic_ostream&ltchar, _Traits>& std::operator<<(std::basic_ostream&ltchar, _Traits>&, char) [with _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:447: error: std::basic_ostream&ltchar, _Traits>& std::operator<<(std::basic_ostream&ltchar, _Traits>&, signed char) [with _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:452: error: std::basic_ostream&ltchar, _Traits>& std::operator<<(std::basic_ostream&ltchar, _Traits>&, unsigned char) [with _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:580: error: std::basic_ostream&lt_CharT, _Traits>& std::operator<<(std::basic_ostream&lt_CharT, _Traits>&, const char*) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/bits/ostream.tcc:630: error: std::basic_ostream&ltchar, _Traits>& std::operator<<(std::basic_ostream&ltchar, _Traits>&, const char*) [with _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:486: error: std::basic_ostream&ltchar, _Traits>& std::operator<<(std::basic_ostream&ltchar, _Traits>&, const signed char*) [with _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/ostream:491: error: std::basic_ostream&ltchar, _Traits>& std::operator<<(std::basic_ostream&ltchar, _Traits>&, const unsigned char*) [with _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/iomanip:82: error: std::basic_ostream&lt_CharT, _Traits>& std::operator<<(std::basic_ostream&lt_CharT, _Traits>&, std::_Resetiosflags) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/iomanip:116: error: std::basic_ostream&lt_CharT, _Traits>& std::operator<<(std::basic_ostream&lt_CharT, _Traits>&, std::_Setiosflags) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/iomanip:154: error: std::basic_ostream&lt_CharT, _Traits>& std::operator<<(std::basic_ostream&lt_CharT, _Traits>&, std::_Setbase) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/iomanip:227: error: std::basic_ostream&lt_CharT, _Traits>& std::operator<<(std::basic_ostream&lt_CharT, _Traits>&, std::_Setprecision) [with _CharT = char, _Traits = std::char_traits&ltchar>]/usr/local/include/c++/3.3/iomanip:261: error: std::basic_ostream&lt_CharT, _Traits>& std::operator<<(std::basic_ostream&lt_CharT, _Traits>&, std::_Setw) [with _CharT = char, _Traits = std::char_traits&ltchar>]

Recommended Answers

All 16 Replies

You have this : "<< printMonth(x);"

In most of your function. Take out the "<<"
and let it just be printMonth().

thanks but what about my third error

First (line 32) error maide cause you close your cout on the line above, chek that out.
Same mistake Line 43;
And last mistake: function lastmouth should be an int not a void


Edit the first two erros I was wrong you dou in fact print them out inside the functions.

last error still there even if i change it to an int

now um getting a new error no match for `void << std::_Setw' operator

Are you sure??? i just compile it
here

#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]);
int 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;
}
}

int 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;
}
}

thanks it works now

now i cant get my table to work correctly it still complies and i can enter in the rain falls but it doesn't show up in my table i am getting some weird things coming up so if someone can compile this and run it and see what the problem is this time and can tell me that would be great

now i cant get my table to work correctly it still complies and i can enter in the rain falls but it doesn't show up in my table i am getting some weird things coming up so if someone can compile this and run it and see what the problem is this time and can tell me that would be great

jaja okey but it will take a while

thanks man

pufff i got this so far

#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]);
int 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 << endl << setw(7) << printMonth(n) << setw(8) << actual << setw(9) << average << setw(10) << difference << endl;
             system("pause");
     }
}

int 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;
    }
}

I still need to fix the dysplay result

ya i need the name of the month under month i need the number for actual rainfall under actual same for average and difference

i dont want those weird attachments to the name of the month either or the 12 going down 12 times

if this doesn't work i give up

#include <iostream>
#include <iomanip>
using namespace std;

//global constants
const int SIZE = 12;
double rainfall[SIZE]; 
double averages[SIZE];
//function prototypes
bool getAverageRainFall(const char* test); 
bool getExactRainFall(const char* working);
void displayResults(const char* got_it);
int 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()
{
getAverageRainFall("test");
getExactRainFall("working");
displayResults("got_IT");
return 0;
}

bool getAverageRainFall(const char* test)
{
     for(int x=0; x<SIZE; x++)
     {
             cout << "Enter the average rainfall: ";
             printMonth(x);
             cin >> averages[x];
     }
}


bool getExactRainFall(const char* working)
{
     for(int x=0; x<SIZE; x++)
     {
             cout << "Enter the actual rainfall: ";
             printMonth(x);
             cin >> rainfall[x]; 
     }
}


void displayResults(const char* got_it)
{
     double difference;
     difference = rainfall - averages;
     cout << "Month Actual Average Difference";
     for(int n=0; n<SIZE; n++)
     {
             cout << endl << setw(7) << printMonth(n) << setw(8) << rainfall << setw(9) << averages << setw(10) << difference << endl;
             system("pause");
     }
}

int 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;
    }
}

just erase the system("PAUSE")
what attachments???? blank spaces???

can someone me make an astrisk bar graph for my data and it needs two bars for each month one for average ad one for actual

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.