Question
File: fixit5.php Purpose: What's wrong here? This program is supposed to open a file for reading, read three first names. last names, and wage amounts
File: fixit5.php Purpose: What's wrong here? This program is supposed to open a file for reading, read three first names. last names, and wage amounts from the file, close the file, calculate the total and average, and display the employees' names and wages, total and average. But when the program runs, the output is very strange!
Hint: Look at the wages2.txt file to see how the data is stored Now look at how this data is being parsed - the problem has to do with the explode() functions. -->
WAGE REPORT
$employee1 = fgets($wageFile); // reads data for the 1st employee from the file $employee2 = fgets($wageFile); // reads data for the 2nd employee from the file $employee3 = fgets($wageFile); // reads data for the 3rd employee from the file fclose($wageFile);
list($firstName1, $lastName1, $wage1) = explode(":", $employee1); list($firstName2, $lastName2, $wage2) = explode(":", $employee2); list($firstName3, $lastName3, $wage3) = explode(":", $employee3);
$totalWages = $wage1 + $wage2 + $wage3; $avgWage = $totalWages/3;
print("
$lastName1, $firstName1: $$wage1 "); print("$lastName2, $firstName2: $$wage2 "); print("$lastName3, $firstName3: $$wage3
"); print("TOTAL WAGES PAID: $$totalWages
"); print("AVERAGE WAGE: $$avgWage
"); ?>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