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 (string)-leaners 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 if-else statements. Here's a sample grading scale:
a. A: 90-100
b. B: 80-89
c. C: 70-79
d. D: 60-69
e. F: Below 60
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
user-friendly format (e.g., "Student Name: Mary Jane, Average: 68.5, Letter
Grade: B").

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 Programming Questions!