Question: Using C++ A text file has an employee database in the following format. FirstName LastName Salary The salary value has special characters such as $.

Using C++

A text file has an employee database in the following format. FirstName LastName Salary The salary value has special characters such as $. Write a program to find the average salary of the employees. You HAVE to read all three parameters as strings. Standard C++ does not support converting string to doubles. So, you MUST first convert this string to a C-string. Then, call the function that converts C-strings to floating point numbers. Use HW8Prob1.dat file for your program.

HINT:

1. Use the string library functions to do this problem. Declare three strings variables, read the file one line at a time and assign the read values to correct variables.

2. For the salary parameter, use substr() function to grab the part of string without the $ sign.

HW8Prob1.dat:

John Harris $50000.00 Lisa Smith $75000.75 Adam Johnson $68500.50 Sheila Smith $150000.50 Tristen Major $75800.76 Yannic Lennart $58000.55 Lorena Emil $43000.00 Tereza Santeri $48000.01

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!