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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started