Declare 3 variables for 3 different courses, and assign values to them. Using HTML form getting handled by PHP. So use 3 text boxes for 3 different courses grades Calculate the GPA and display it on the screen

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter7: Designing A Web Form: Creating A Survey Form
Section: Chapter Questions
Problem 5CP2
icon
Related questions
Question
Declare 3 variables for 3 different courses, and assign values to them. Using HTML form getting handled by PHP.
So use 3 text boxes for 3 different courses grades
Calculate the GPA and display it on the screen
Expert Solution
Step 1

Algorithm steps of HTML:

  1. Start
  2. Create an HTML document with the title "GPA Calculator".
  3. Create a form element with a method of "post" and an action of "calculate-gpa.php".
  4. Within the form element, create a heading 2 element with the text "GPA Calculator".
  5. Create a label element with the text "Course 1:", and an input element of type "text" with the name "course1" and an id of "course1".
  6. Create a label element with the text "Course 2:", and an input element of type "text" with the name "course2" and an id of "course2".
  7. Create a label element with the text "Course 3:", and an input element of type "text" with the name "course3" and an id of "course3".
  8. Create a line break element.
  9. Create an input element of type "submit" with the name "submit" and the value "Calculate GPA".
  10. End the form element.
  11. End the HTML document.

Algorithm steps of Php:

  1. Start
  2. Check if the submit button was clicked or not by using the isset() function in PHP.
  3. If the submit button was clicked, retrieve the marks obtained in each course using the $_POST superglobal variable and store them in their respective variables: $course1, $course2, and $course3.
  4. Calculate the total marks obtained by adding the marks in all three courses together, and store it in a variable called $total_marks.
  5. Calculate the GPA by dividing the total marks by 3, and store it in a variable called $gpa.
  6. Display the calculated GPA using the echo statement with a string message and the calculated GPA. The number_format() function is used to format the GPA with two decimal points.
  7. End the PHP script.
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Elements and Tags
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning