Hello i need help with a program i have to write for my class. I am stuck and still pretty new to coding. I would appreciate any and all help.
the assignment is this:
You are the game warden in your town and are responsible for stocking the local lake
(see Figure 1) prior to the opening of the fishing season. The average depth of the lake is
20 feet. Your plan is to stock the lake with 1 fish per 1000 cubic feet, and have
approximately 25% of the original fish population remaining at the end of the season.
What is the maximum number of fishing licenses that can be sold if the average catch is
20 fish per license?
The program criteria are:
1. Present the user with a short greeting describing the program.
2. Read the name of the data file from the command line in argv[1].
3. Open the file, read the data and save it in an array.
4. Compute the volume of the lake using Simpson’s rule and the other statistics
necessary to find the maximum number of licenses that can be sold.
5. Display the final answer with an annotation.
This is my main
#include <iostream>
#include <fstream>
#include <cstdlib>
#include "pa1functions.h"
#include "pa1functions.cpp"
int main(int argc, char* argv[])
{
functions::greeting(); //Function to greet user and explain program
functions::read_data();//Read data from file using argv[1]
functions::get_data();//Open file, read and save file to array
functions::compute();//Compute volume and licenses
functions::answer();//Display annotated answer
//Not sure if calling the functions properly. I know the should be something in the ()
return 0;
}
This is the function prototype
namespace functions
{
void greeting();
int read_data();
int get_data();
double area();
double volume();
void answer();
}
and these are the functions(where i am having the most trouble)
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include "pa1functions.h"
void functions::greeting()
{
using std::cout;
using std::cin;
using std::endl;
cout <<"Hello Game Master this program will compute the lake volume then\n"; cout <<"find how many fish to put in the lake and determine how many\n";
cout <<"fishing licenses to sell to keep 25% of the fish population still\n";
cout <<"in the lake.\n";
cout <<"Press any key and ENTER to continue:";
char x;
cin >> x;
cout << endl;
}
int functions::read_data()
{
using std::cout;
using std::cin;
using std::cerr;
using std::ifstream;
const char* inFile = "lake.txt";
cout << "Please enter the name of the file with the lake information\n";
cout << "then press ENTER ->\n";
//Could not get away for the user to imput the file name and have the code work.
//so i just assigned inFile to the txt file i had.
//and the txt file can be any 8 numbers i just used 2-16 seperated with spaces
ifstream in(inFile);//opening the file for reading
if(!in)
{
cerr << "Error, the file could not be opened!\n";
return (-1);
}
int lake_data[8];
while(!in.eof())
{
in.get
}
}