Question: Provide PHP code to create a learner grade calculator program with following specifications - In the calculator program, define learner class with name and grades,
Provide PHP code to create a learner grade calculator program with following specifications
In the calculator program, define learner class with name and
grades, functions to calculate the average and determine letter grade based on the
average, and a loop to process multiple leaners with user input for their grades.
Class: learner
Define a class named leaner with
name stringleaners name,
grades array Array containing leaner grades integers
Implement a constructor method that takes the student's name and an array of
grades as arguments and initialises the corresponding properties.
Function: calculateAverage:
Create a function named calculateAverage that takes a learner object as
an argument.
Inside the function, loop through the student's grades array and calculate
the average grade.
The function should return the calculated average grade float
Develop a function named determineLetterGrade that takes a float average
grade as an argument.
Implement a logic to determine the letter grade based on the average using
a switch statement or ifelse statements. Here's a sample grading scale:
a A:
b B:
c C:
d D:
e F: Below
The function should return the corresponding letter grade string
Within the main PHP file:
Create an array of learner names.
Loop through the learner names array.
For each leaner, prompt the user to enter their grades integers one by
one using a loop. Store these grades in an array
Create a new learner object by passing the learner's name and their grade
array to the constructor.
Call the calculateAverage function with the learner object as an argument
and store the returned average.
Call the determineLetterGrade function with the calculated average and
store the returned letter grade.
then, display the learner's name, average grade, and letter grade in a
userfriendly format eg "Student Name: Mary Jane, Average: Letter
Grade: B
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
