Can somebody help me with this assignment? I am a very beginner level c++ user and this thing has flown over ma head. I know there are some c++ gurus around who can surely help me with this.
1) For this assignment, fill out the following class:
class person {
private: string firstName;
string lastName;
int weight;
public:
. . .
};
You should provide constructors, access functions, and the operator>>.
2) Write a main function that opens an ifstream on the input file, "person.dat". If the stream cannot be opened, output an error message and exit.
The file format is as follows: last_name comma first_name comma weight newline
3) Continuing in your main, open an ofstream to use for output to a file named "output.dat". If the stream cannot be opened, output an error message and exit.
4) Continuing in main, write a loop that will read from the ifstream that reads enough information to create a person object (i.e. first name, last name, and weight). Exit the loop on end-of-file. If there is an error reading the information, output an error message and exit the program.
5) For each person read in (4), decrement their weight by 5 pounds and use the overloaded operator>> to output each person object to the ofstream created in (3) IN THE SAME FORMAT as the original file.
6) Use the given file, person.dat, for example input, but you should try some exceptional cases to make sure your code can detect and properly handle them.