# Special Prize to whoever finds the errors

Printable View

• 08-02-2007
benjamin923
Special Prize to whoever finds the errors
Challenge problem: Where are the two errors???
Code:

```//Homework 18.4 //Benjamin Stollerman //CS 1050 #include <iostream.h> #include <fstream.h> #include <iomanip.h> using namespace std; int main() {         //Define and initialize variables and 2D array         double lake[5][12];         double num_years[5];         double average[5];         double num=0;         //Attach object name         fstream powell_data;         // Associate object name to a file         powell_data.open("lake_powell.dat",ios::in);         /*Part A- Calculate the average elevation of the water level for each year         and for 5 year period*/         for(int k=0; k<12; k++)         //for loop         {                 for(int j=0; j<5; j++)                 powell_data>>lake_data[j][k];                 //read in the data from above         }         for(int k=0; k<5;k++)         {                 num_years[k] = 0;                 for(int j=0; j<12; j++)                         num_years[k] = lake[k][j]+1;                 num += num_years[k];         }         for(int k=0; k<5; k++)         {                 average[k]=0;                 for(int j=0; j<12; j++)                 {                         if(lake[k][j] > (num_years[k]/12))                         average[k] = average[k]+1;                 }                 cout<<"In "<<k+2000<<"The average elevation was: "<<(num_years[k]/12)<<endl;                 cout<<"There were "<<average[k]<<" months above average"<<endl;         }         cout<<"The 5-year average elevation was: "<<(total/60)<<endl;         return 0; }```
Thankee very much!
• 08-02-2007
Desolation
First error: You posted a C++ question in a C forum.
Second error: Your code uses deprecated header files.
Bonus error: You didn't tell us what kind of error to look out for.
• 08-02-2007
benjamin923
lol - at least you know that i'm no expert.
thanks for taking a look anyways.
• 08-02-2007
Salem
What's the prize?

If there is no actual prize, it's just a pathetic attempt to solicit special interest in your post.
• 08-03-2007
MacGyver
Extra Bonus error: You're posting multiple topics about the same thing.
• 08-03-2007
zacs7
Plus you're posting it in the wrong place each time!
Ding ding ding!
• 08-03-2007
markcole
In
Code:

`powell_data.open("lake_powell.dat",ios::in);`
the filename is wrong.
• 08-03-2007
pianorain
Quote:

Originally Posted by benjamin923
Challenge problem: Where are the two errors???
Code:

`//Homework 18.4`

This made me laugh.
• 08-03-2007
MacGyver
Quote:

Originally Posted by pianorain
This made me laugh.

Kids trying to get us to do their homework are morons because this kind of crap will bite them later on when they're unable to do a single thing during the tests. It gets even better if they get a degree for which they don't have the associated knowledge.

I'm preaching to the choir, I know, but I'm hoping that the OP actually reads this if I mention it this way. ;)
• 08-03-2007
Frobozz
Quote:

Originally Posted by MacGyver
Kids trying to get us to do their homework are morons because this kind of crap will bite them later on when they're unable to do a single thing during the tests. It gets even better if they get a degree for which they don't have the associated knowledge.

I totally agree. I've run across programmers at places I've worked (VB .NET programmers to be precise) and they were total idiots. The software crashed constantly because they didn't account for typos in certain fields (like text boxes expecting numbers and you hit a letter - CRASH!).

Edit: After a quick compile, I'll offer the suggestion that you check your variables and the scope they are used in.
• 08-03-2007
Oldman47
I highly doubt that many individuals looking for a quick homework solution are going to be programming as a profession. Moreso, most are simply trying to get through the course, get the credit for it and put the misery behind them. We're geeks and freaks (and old men with nothing better to do) who actually like programming, but for many taking the course it's almost as distastful to them as gym class.
• 08-03-2007
Frobozz
Well the only other field I can think of that would require this is engineering. And if he can't handle this, he probably will have a hard time with engineering as well. For other degrees I can't imagine the language they force on them is C++. For my community college it was VBScript. :p