Line 7: Missing a close comment (*/)
Line 24: ne555 gave you two examples. One as a stand-alone function and one as a member function. You're using the wrong example as a member function. Note that the member function does not take an argument.
1 2 3 4 5 6 7 8
|
// Member function
bool habitable() const
{ return
distance >= 100 || distance <= 75
&& type == terrestrial // see comment below about this line
&& diameter <= 10000 || diameter >= 5000
&& avgTemp >= 45 || avetemp <= 75;
}
|
Line 28: You're comparing type to terrestrial, but terrestrial is never defined. Since type is a char array, you should be using strcmp and compare a quoted string.
|
&& strcmp(type, "terrestrial") == 0
|
Better to use C++ std::string than C-style strings.
Line 30: Missing a ;
Line 31: Missing a }
Line 98,119: The correct way to use a member function:
|
cout << "habitbale: " << (planet[planetNum].habitable() ? "yes" : "no") << endl;
|
edit:
Lines 91-98 and 112-120 do exactly the same thing. You should create a member function to display information about a planet.
1 2 3 4 5 6 7 8 9
|
// member function
void Display () const
{ cout << "Name: " << name << endl;
cout << "Diameter: " << diameter << " " << "miles" << endl;
cout << "Distance from star: " << distance << " " << "million miles" << endl;
cout << "Average temperature: " << avgTemp << " " << "Degrees F" << endl;
cout << "type: " << type << endl;
cout << "habitable: " << (habitable() ? "yes" : "no") << endl;
}
|
Line 27: Don;t you have the following condition wrong?
|
planet.distance >= 100 || planet.distance <= 75
|
That states the planet must be more than 100M miles or less than 75M miles from the sun.
Shouldn;t the condition be:
|
distance >= 75 && distance <= 100
|
I'd suggest checking your other conditions also. diameter and avgTemp conditions are questionable.