Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago