C++ Program Struct, I/O Files, Lawn Mowing Competition

I have an assignment for class and would like some help organizing it. The assignment is that a group of students have been hired by a private company for mowing lawns. These students will be in a competition where whoever obtains the biggest value of target, 0.75*area+0.25*speed, speed=area/hours, area=length*width, wins the competition. We have an input file organized like this:

(Name length width hours)
Allan 65 55 2.5

Output should look like this:
Name length width hours target
James 67.00 89.50 4.50 4830.5137

The struct is built like this:
struct stuLawnMowed {
char stuName[20];
float length;
float width;
float hours;
};

And we must include these 3 functions:
float getTarget(stuLawnMowed s); //return target value
void sortArray(stuLawnMowed slm[], int len); //calls getTarget()
bool sortStuLawnMowed(char inFile[], char outFile[]); //calls sortArray()

int main() {
if (sortStuLawnMowed("lawnMowing.txt", "sortedLawnMowing.txt"))
cout << "Student mowed lawns have been sorted.\n";
} (This can't be changed)

So far I have this:

float getTarget(stuLawnMowed s)
{
float area = s.length * s.width;
float speed = area / s.hours;
float target = 0.75*area + 0.25*speed;
return target;

}

Trying to figure out the other two functions.
Last edited on
Topic archived. No new replies allowed.