Advertisement
Hydrase

Marks

Jun 8th, 2025
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Student Grade Calculator</title>
  5. </head>
  6. <body>
  7. <h2>Enter Marks for 6 Subjects (out of 100)</h2>
  8. <form method="post">
  9. <?php
  10. for ($i = 1; $i <= 6; $i++) {
  11. echo "Subject $i: <input type='number' name='sub$i' min='0' max='100' required><br><br>";
  12. }
  13. ?>
  14. <input type="submit" name="submit" value="Calculate Grade">
  15. </form>
  16.  
  17. <?php
  18. if (isset($_POST['submit'])) {
  19. $total = 0;
  20. for ($i = 1; $i <= 6; $i++) {
  21. $marks = $_POST["sub$i"];
  22. $total += $marks;
  23. }
  24.  
  25. $percentage = ($total / 600) * 100;
  26.  
  27. echo "<h3>Total Marks: $total / 600</h3>";
  28. echo "<h3>Percentage: " . round($percentage, 2) . "%</h3>";
  29.  
  30. // Grade Calculation
  31. if ($percentage < 40) {
  32. echo "<h3>Grade: Failed</h3>";
  33. } elseif ($percentage < 50) {
  34. echo "<h3>Grade: D</h3>";
  35. } elseif ($percentage < 60) {
  36. echo "<h3>Grade: C</h3>";
  37. } elseif ($percentage < 70) {
  38. echo "<h3>Grade: B</h3>";
  39. } elseif ($percentage < 80) {
  40. echo "<h3>Grade: B+</h3>";
  41. } elseif ($percentage < 90) {
  42. echo "<h3>Grade: A</h3>";
  43. } else {
  44. echo "<h3>Grade: A+</h3>";
  45. }
  46. }
  47. ?>
  48. </body>
  49. </html>
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement