HW8

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

PIC 10A Homework 8 (100pt)

Problem 8 (100pt): File input/output manipulations. This homework reviews the topics
of: input/output file stream, string stream, formatted output and class.

main.cpp reads employee information from a file employee.txt, saves all employees in a
vector, gives all employees a raise by 15%, and outputs updated employee information to
a file, called raise.txt. Implement Employee class and two functions read employee and
write employee to make main.cpp compile. Check main.cpp first to see how the class and
functions are used.

Employee class contains two private variables: name and salary, and other public functions.
Define the class as needed.

Each line in employee.txt has 40 characters in the format:


[employee name (takes up 30 characters)][salary (takes up 10 characters)]

read employee(e, in) reads one employee’s information from a stream in and save the
information into the parameter: employee object e. write employee(e, out) writes em-
ployee e’s information to a stream out with the same format in employee.txt, where each
employee takes up one line (40 characters):
[employee name (takes up 30 characters)][salary (takes up 10 characters)]

The raise.txt looks like

Instructions:
• (10pt) Separate your code into two files: Employee.h (class interface, function dec-
laration) and Employee.cpp (class implementation, function implementation). Add
description of files in the beginning to show your ownership.
• (20pt) Write your code with good coding practices. Comment on your code to make it
readable. To receive full credits, all parameter lists should be declared with the best
practice.
• (70pt) You are not allowed to modify main.cpp. Your files must compile with the
given main.cpp and generates a file raise.txt with the above format. Remember to
check your homework with PIC virtual lab desktop if you don’t code with VS 2019.

You might also like