Second Pair of Eyes for School Assignment

I've been searching online for various issues I'm having and I've been editing
and reading and I am down to four errors and just cannot figure out why my
program won't run. I would really appreciate a second (or third or fourth)
pair of eyes to look over my code and see why my issues may be.

ManateeSighting.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef MANATEESIGHTING_H
#define MANATEESIGHTING_H

class ManateeSighting
{
private: 
	std::string location;
	std::string sightDate[50];
    int manateeCount[50];
	int numCount;
    double avg;         // Average count for location
    int maxCnt;         // Maximum count for location
    std::string maxDate;     // Date maximum recorded
    std::string monthWithMostSightings;

public:
	// Constructor
    ManateeSighting::ManateeSighting(std::string loc, std::string date[],
                            int cnt[], int numOfFlights)
    {
        for(int x = 0; x < numOfFlights; x++)
		{
			sightDate[x] = date[x];
			manateeCount[x] = cnt[x];
		}
		numCount = numOfFlights;
        location = loc;
    }

    std::string ManateeSighting::GetLocation()
    {
		return location;
    }

	std::string ManateeSighting::SetLocation(std::string loc)
    {
            location = loc;
    }

    std::string ManateeSighting::MonthWithMostSightings()
    {
		DetermineMax();
        return monthWithMostSightings;
    }

    double ManateeSighting::Avg()
	{
        CalculateAvg();
        return avg;
    }

    int ManateeSighting::MaxCnt()
    {
        DetermineMax();
        return maxCnt;
    }

    std::string MaxDate()
    {
        DetermineMax();
        return maxDate;
    }

    // Determine the average number of sightings per location
    void ManateeSighting::CalculateAvg()
    {
        int total = 0;
        for each(int c in manateeCount)
        total += c;
        avg = total / numCount;
    }

    // Determines the maximum number of manatees
    // sighted on any one given date.  Uses a parallel
    // array to determine the actual date.
    // Calls method to set the month name.
    void ManateeSighting::DetermineMax()
    {
        int maxCntIndex = 0;
        for (int i = 1; i < numCount; i++)
        {
			if (manateeCount[i] > manateeCount[maxCntIndex])
                maxCntIndex = i;
		}
        maxCnt = manateeCount[maxCntIndex];
        maxDate = sightDate[maxCntIndex];
        monthWithMostSightings = ReturnMonth(maxDate);
    }

    // Given a date in the format of mm/dd/yyyy
    // the name of the month is returned.
    std::string ManateeSighting::ReturnMonth(std::string someDate)
    {
        std::string monthName[] = {"January", "February", "March",
                                "April", "May", "June", "July",
                                "August", "September",
                                "October", "November",
                                "December"};

	
        int datePosition = someDate.find('/');
		std::string strDateOfMonth = someDate.substr(0, datePosition);
		int dateOfMonth = FromString<int>(strDateOfMonth);
        return monthName[dateOfMonth - 1];
    }

	template<typename T>
	T FromString(const std::string& str)
	{
		std::istringstream ss(str);
		T ret;
		ss >> ret;
		return ret;
	}
}

#endif 


ManateeApp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <iomanip>
#include <string>
#include "ManateeSighting.h"

int main()
{
    std::string location;
    int sightingCnt;
    std::string dArray [50];
    int manateeCnt [50];
	std::string outLocation[1];
    sightingCnt = GetData(outLocation, dArray, manateeCnt);

    ManateeSighting m(location, dArray, manateeCnt, sightingCnt);

    
    std::cout << "\n\nLocation:  " << m.GetLocation() << std::endl;
    std::cout << "Average Number of Sightings:  " <<  m.Avg() << std::endl;
    std::cout << "Month Name for Date with Most Sightings:  " 
		      << m.MonthWithMostSightings() << std::endl;
    std::cout << "Date of the Most Sightings:  " << m.MaxDate() << std::endl;
    std::cout << "Count for " << m.MaxDate() << ":  " 
			  << m.MaxCnt() << std::endl;
    system("pause");
	
	return 0;
}

static int GetData(std::string outLocation[],
        std::string dArray[], int manateeCnt[])
{
	int i;
	int inValue;

	std::cout << "Location:  ";
    std::cin >> outLocation[0];
    std::cout << "How many records for " << outLocation[0] << "?  ";
    std::cin >> inValue;
    for (i = 0; i < inValue; i++)
    {
        std::cout << "Date (mm/dd/yyyy):  ";
        std::cin >> dArray[i];
        std::cout << "Number of Sightings:  ";
        std::cin >> manateeCnt[i];
    }
    return i;
}


Errors
1
2
3
4
Error	1	error C2628: 'ManateeSighting' followed by 'int' is illegal (did you forget a ';'?)	c:\visual studio 2010\projects\c++ manatee sighting - solution\c++ manatee sighting\manateeapp.cpp	12	1	C++ Manatee Sighting
Error	2	error C3874: return type of 'main' should be 'int' instead of 'ManateeSighting'	c:\visual studio 2010\projects\c++ manatee sighting - solution\c++ manatee sighting\manateeapp.cpp	13	1	C++ Manatee Sighting
Error	3	error C3861: 'GetData': identifier not found	c:\visual studio 2010\projects\c++ manatee sighting - solution\c++ manatee sighting\manateeapp.cpp	19	1	C++ Manatee Sighting
Error	4	error C2664: 'ManateeSighting::ManateeSighting(const ManateeSighting &)' : cannot convert parameter 1 from 'int' to 'const ManateeSighting &'	c:\visual studio 2010\projects\c++ manatee sighting - solution\c++ manatee sighting\manateeapp.cpp	33	1	C++ Manatee Sighting
Last edited on
closed account (D80DSL3A)
Line 115 } should be }; as the 1st error suggests.
Topic archived. No new replies allowed.