Skip to content

ikram4dev/php-moyenne-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🎓 Student Average Calculator (PHP Project)

📘 Description

This simple PHP web app allows users to input their name and five grades, then calculates their average (moyenne) and displays a personalized comment depending on whether they passed or failed.

It includes:

  • Basic form handling with POST requests.
  • Validation to ensure all fields are filled and grades are between 0 and 20.
  • Error messages for invalid input.
  • A result section showing the student’s name, calculated average, and a comment.

🧮 Features

✅ Input of student name and five grades. ✅ Validation for empty fields and invalid grade values. ✅ Average calculation (sum of grades ÷ number of grades). ✅ Friendly output message:

  • 🎉 “Félicitations ! vous êtes admis” if average ≥ 10
  • 😞 “Malheureusement vous repassez l’examen” if average < 10

🛠️ Technologies Used

  • PHP (for backend logic)
  • HTML5 (for structure)
  • CSS (optional, linked as style.css for styling)

🚀 How to Run the Project

  1. Clone or download the project files into your web server directory (e.g., htdocs for XAMPP or www for WAMP).

  2. Make sure your local PHP server is running (e.g., http://localhost).

  3. Open your browser and go to:

    http://localhost/your_project_folder/
    
  4. Fill out the form with your name and five grades.

  5. Click “calcul” to see your average and result message.


⚠️ Notes

  • Make sure all grades are between 0 and 20.
  • The form uses required attributes, but validation is also handled in PHP for security.
  • You can modify the number of grades by adding or removing <input> fields in the HTML form and adjusting the PHP logic if needed.

📂 File Structure

student-average/
│
├── index.php        # Main PHP file (contains form and logic)
├── style.css        # Optional stylesheet for layout and colors
└── README.md        # Project documentation

🧑‍💻 Example Output

Input: Name: Ali Notes: 12, 14, 9, 16, 10

Output:

Your name: Ali  
Your moyenne: 12.20  
Félicitations ! vous êtes admis

✨ Future Improvements

  • Add support for a dynamic number of grades.
  • Include letter grading (A, B, C...) based on average.
  • Store results in a database (MySQL).
  • Improve UI with Bootstrap or TailwindCSS.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published