<html>
<head>
<title>Grade Calculator</title>
</head>
<?php
?>
<body>
<?php
$grade = $_POST["Quiz1"] * 0.05 + $_POST["Mid-Term"] * 0.30 + $_POST["Quiz2"] * 0.05 + $_POST["AL1"] * 0.05 + $_POST["AL2"] * 0.05 + $_POST["Participation"] * 0.10 +  $_POST["Final"] * 0.40  ;
?>
<?php
echo "Grade Report: <br />";
echo "<br />";
?>
Your final grade percentage will be:  <?php echo $grade ;
echo "<br />";
{
if ($grade > 90.9)
	echo "Your final grade for the course will be: A+ <br />";
elseif ($grade > 85.9)
	echo "Your final grade for the course will be: A  <br />";
elseif ($grade > 79)
	echo "Your final grade for the course will be: A-  <br />";
elseif ($grade > 76.9)
	echo "Your final grade for the course will be: B+  <br />";
elseif ($grade >71.9)
	echo "Your final grade for the course will be: B  <br />";
elseif ($grade > 69.9)
	echo "Your final grade for the course will be: B-  <br />";
elseif ($grade > 65.9)
	echo "Your final grade for the course will be: C+  <br />";
elseif ($grade > 59.9)
	echo "Your final grade for the course will be: C  <br />";
elseif ($grade > 54.9)
	echo "Your final grade for the course will be: C-  <br />";
elseif ($grade > 49.9)
	echo "Your final grade for the course will be: Pass  <br />";
else
	echo "Your final grade for the course will be: Fail  <br />";

}

?>
</body>
</html>

Above is the code I have used for my php program which is linked to a html file, this program calculates grades, everything is correct, except for the fact that If the user selects the option "not done yet / excused", it must be able to calculate without taking the % of the whatever quzi, mid-term, etc that that they missed, ie if they have only taken 50% of the available marks in the course, it must be able to just calculate that.

Could someone help me on this, any help is greatly appreciated

Thanks,

Tony

Something simple and straightfowrd...

$grade = 0;
if ($_POST['QUIZ1'] >= 0 && $_POST['QUIZ1'] <= 100)
	$grade = $grade + $_POST['QUIZ1'] * 0.05;
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
	$grade = $grade + $_POST['Mid-Term'] * 0.30;
//continue code like this until you've included all the scores

Something simple and straightfowrd...

$grade = 0;
if ($_POST['QUIZ1'] >= 0 && $_POST['QUIZ1'] <= 100)
	$grade = $grade + $_POST['QUIZ1'] * 0.05;
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
	$grade = $grade + $_POST['Mid-Term'] * 0.30;
//continue code like this until you've included all the scores

Hi, I tried using ur code, but it still shows 51.45%, given that, for 2 inputs, al2 and final, i entered "not done yet / excused:", because in my prof gradebook, it calculates at 91.5%.......Below is the code i implemented:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title>Grade Calculator</title>
</head>
<?php
?>
<body>
<?php
$grade = 0;
if ($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100)
	$grade = $grade + $_POST['Quiz1'] * 0.05;
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
	$grade = $grade + $_POST['Mid-Term'] * 0.30;
if ($_POST['Quiz2'] >= 0 && ($_POST['Quiz2'] <= 100))
	$grade = $grade + $_POST['Quiz2'] * 0.05;
if ($_POST['AL1'] >= 0 && ($_POST['AL1'] <= 100))
	$grade = $grade + $_POST['AL1'] * 0.05;
if ($_POST['AL2'] >= 0 && ($_POST['AL2'] <= 100))
	$grade = $grade + $_POST['AL2'] * 0.05;
if ($_POST['Participation'] >= 0 && ($_POST['Participation'] <= 100))
	$grade = $grade + $_POST['Participation'] * 0.10;
if ($_POST['Final'] >= 0 && ($_POST['Final'] <= 100))
	$grade = $grade + $_POST['Final'] * 0.40;
?>
<?php
echo "Grade Report: <br />";
echo "<br />";
?>
Your final grade percentage will be:  <?php echo $grade . "%";
echo "<br />";
{
if ($grade > 90.9)
	echo "Your final grade for the course will be: A+ <br />";
elseif ($grade > 85.9)
	echo "Your final grade for the course will be: A  <br />";
elseif ($grade > 79)
	echo "Your final grade for the course will be: A-  <br />";
elseif ($grade > 76.9)
	echo "Your final grade for the course will be: B+  <br />";
elseif ($grade >71.9)
	echo "Your final grade for the course will be: B  <br />";
elseif ($grade > 69.9)
	echo "Your final grade for the course will be: B-  <br />";
elseif ($grade > 65.9)
	echo "Your final grade for the course will be: C+  <br />";
elseif ($grade > 59.9)
	echo "Your final grade for the course will be: C  <br />";
elseif ($grade > 54.9)
	echo "Your final grade for the course will be: C-  <br />";
elseif ($grade > 49.9)
	echo "Your final grade for the course will be: P  <br />";
else
	echo "Your final grade for the course will be: F  <br />";

}

?>
</body>
</html>

Thanks in advance

Tony

It looks like you're calculating them to have full credit if they haven't taken the exam, if that's the case...

if ($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100)
   $grade = $grade + $_POST['Quiz1'] * 0.05;
else
  $grade = 5;

But even easier than this is when you set the html form, set the html value="100" so you wont have to worry about the else statment.
for example

echo "\n".'<option value="100">Not Done Yet / Excused</option>';
for ($i=100; $i>-1; $i--) {
  echo "\n".'<option value="'.$i.'">'.$i.'%</option>';
}

Oops, the
$grade = 5;
is supposed to
$grade = $grade + 5;

Oops, the
$grade = 5;
is supposed to
$grade = $grade + 5;

Sorry to trouble you, but it still does not seem to work, my code:

<!--
// Group members:Bala, Andre Tan, Leo Tse
// Date: Thursday July 11 2009
// Purpose: Write a PHP program that can calculate grades for students of CSCI 110
-->
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title>Grade Calculator</title>
</head>
<?php
?>
<body>
<?php
$grade = 0;
if ($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100)
	$grade = $grade + $_POST['Quiz1'] * 0.05;
else
  	$grade = $grade + 5; 
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
	$grade = $grade + $_POST['Mid-Term'] * 0.30;
else
  	$grade = $grade + 30; 
if ($_POST['Quiz2'] >= 0 && ($_POST['Quiz2'] <= 100))
	$grade = $grade + $_POST['Quiz2'] * 0.05;
else
  	$grade = $grade + 5; 
if ($_POST['AL1'] >= 0 && ($_POST['AL1'] <= 100))
	$grade = $grade + $_POST['AL1'] * 0.05;
else
   	$grade = $grade + 5; 
if ($_POST['AL2'] >= 0 && ($_POST['AL2'] <= 100))
	$grade = $grade + $_POST['AL2'] * 0.05;
else
  	$grade = $grade + 5; 
if ($_POST['Participation'] >= 0 && ($_POST['Participation'] <= 100))
	$grade = $grade + $_POST['Participation'] * 0.10;
else
 	$grade = $grade + 10; 
if ($_POST['Final'] >= 0 && ($_POST['Final'] <= 100))
	$grade = $grade + $_POST['Final'] * 0.40;
else
  	$grade = $grade + 40; 
?>
<?php
echo "Grade Report: <br />";
echo "<br />";
?>
Your final grade percentage will be:  <?php echo $grade . "%";
echo "<br />";
{
if ($grade > 90.9)
	echo "Your final grade for the course will be: A+ <br />";
elseif ($grade > 85.9)
	echo "Your final grade for the course will be: A  <br />";
elseif ($grade > 79)
	echo "Your final grade for the course will be: A-  <br />";
elseif ($grade > 76.9)
	echo "Your final grade for the course will be: B+  <br />";
elseif ($grade >71.9)
	echo "Your final grade for the course will be: B  <br />";
elseif ($grade > 69.9)
	echo "Your final grade for the course will be: B-  <br />";
elseif ($grade > 65.9)
	echo "Your final grade for the course will be: C+  <br />";
elseif ($grade > 59.9)
	echo "Your final grade for the course will be: C  <br />";
elseif ($grade > 54.9)
	echo "Your final grade for the course will be: C-  <br />";
elseif ($grade > 49.9)
	echo "Your final grade for the course will be: P  <br />";
else
	echo "Your final grade for the course will be: F  <br />";

}

?>
</body>
</html>

Thanks once again,
Tony

Member Avatar for diafol
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title>Grade Calculator</title>
</head>
<body>
<?php
//QUICK TEST VARIABLES 
$_POST['Quiz1'] = '100';
$_POST['Quiz2'] = '100';
$_POST['Mid-Term'] = '100';
$_POST['AL1'] = '100';
$_POST['AL2'] = '100';
$_POST['Participation'] = '100';
$_POST['Final'] = '100';

//default answer will be 0%
$grade=0;
//calculate $grade percentage from form input (or from quick test variables)
$grade=($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100) ? $grade + ($_POST['Quiz1'] * 0.05) : $grade + 5; 
$grade=($_POST['Mid-Term'] >= 0 && $_POST['Mid-Term'] <= 100) ? $grade + ($_POST['Mid-Term'] * 0.30) : $grade + 30; 
$grade=($_POST['Quiz2'] >= 0 && $_POST['Quiz2'] <= 100) ? $grade + ($_POST['Quiz2'] * 0.05) : $grade + 5;
$grade=($_POST['AL1'] >= 0 && $_POST['AL1'] <= 100) ? $grade + ($_POST['AL1'] * 0.05) : $grade + 5; 
$grade=($_POST['AL2'] >= 0 && $_POST['AL2'] <= 100) ? $grade + ($_POST['AL2'] * 0.05) : $grade + 5; 
$grade=($_POST['Participation'] >= 0 && $_POST['Participation'] <= 100) ? $grade + ($_POST['Participation'] * 0.10) : $grade + 10; 
$grade=($_POST['Final'] >= 0 && $_POST['Final'] <= 100) ? $grade + ($_POST['Final'] * 0.40) : $grade + 40; 

//change these as you need
$pc_array= array(90.9,85.9,79,76.9,71.9,69.9,65.9,59.9,54.9,49.9);
$grade_array=array('A+','A','A-','B+','B','B-','C+','C','C-','P');
$i = 0;
//default answer will be FAIL
$print_grade = 'F';
while($i < count($pc_array)){
	if($grade > $pc_array[$i]){
		$print_grade = $grade_array[$i];
		break;
	}
	$i = $i + 1;
}
// output
echo "<h1>Grade Report: </h1>\n<p>Your final grade percentage will be: {$grade}%</p>\n<p>Your final grade for the course will be: {$print_grade}</p>";

?>
</body>
</html>

I tried the above code and it works fine. The only thing I can think of is that you've mis-named one of your form inputs, so that the $_POST isn't picking it up.

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title>Grade Calculator</title>
</head>
<body>
<?php
//QUICK TEST VARIABLES 
$_POST['Quiz1'] = '100';
$_POST['Quiz2'] = '100';
$_POST['Mid-Term'] = '100';
$_POST['AL1'] = '100';
$_POST['AL2'] = '100';
$_POST['Participation'] = '100';
$_POST['Final'] = '100';

//default answer will be 0%
$grade=0;
//calculate $grade percentage from form input (or from quick test variables)
$grade=($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100) ? $grade + ($_POST['Quiz1'] * 0.05) : $grade + 5; 
$grade=($_POST['Mid-Term'] >= 0 && $_POST['Mid-Term'] <= 100) ? $grade + ($_POST['Mid-Term'] * 0.30) : $grade + 30; 
$grade=($_POST['Quiz2'] >= 0 && $_POST['Quiz2'] <= 100) ? $grade + ($_POST['Quiz2'] * 0.05) : $grade + 5;
$grade=($_POST['AL1'] >= 0 && $_POST['AL1'] <= 100) ? $grade + ($_POST['AL1'] * 0.05) : $grade + 5; 
$grade=($_POST['AL2'] >= 0 && $_POST['AL2'] <= 100) ? $grade + ($_POST['AL2'] * 0.05) : $grade + 5; 
$grade=($_POST['Participation'] >= 0 && $_POST['Participation'] <= 100) ? $grade + ($_POST['Participation'] * 0.10) : $grade + 10; 
$grade=($_POST['Final'] >= 0 && $_POST['Final'] <= 100) ? $grade + ($_POST['Final'] * 0.40) : $grade + 40; 

//change these as you need
$pc_array= array(90.9,85.9,79,76.9,71.9,69.9,65.9,59.9,54.9,49.9);
$grade_array=array('A+','A','A-','B+','B','B-','C+','C','C-','P');
$i = 0;
//default answer will be FAIL
$print_grade = 'F';
while($i < count($pc_array)){
	if($grade > $pc_array[$i]){
		$print_grade = $grade_array[$i];
		break;
	}
	$i = $i + 1;
}
// output
echo "<h1>Grade Report: </h1>\n<p>Your final grade percentage will be: {$grade}%</p>\n<p>Your final grade for the course will be: {$print_grade}</p>";

?>
</body>
</html>

I tried the above code and it works fine. The only thing I can think of is that you've mis-named one of your form inputs, so that the $_POST isn't picking it up.

That's strange, becos it does not work properly with mine, it keeps calculating everything at 100%....Below is my html code:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title> Grade Calculator</title>
</head>
<body>
<h1>CSCI 110 Grade Calculator</h1>
<hr />
<h4>Select your Quiz 1 Score: </h4>
<form method = "post" action = "form3.php">
<select name = "Quiz1">
<option>not done yet / excused</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
<option>53</option>
<option>54</option>
<option>55</option>
<option>56</option>
<option>57</option>
<option>58</option>
<option>59</option>
<option>60</option>
<option>61</option>
<option>62</option>
<option>63</option>
<option>64</option>
<option>65</option>
<option>66</option>
<option>67</option>
<option>68</option>
<option>69</option>
<option>70</option>
<option>71</option>
<option>72</option>
<option>73</option>
<option>74</option>
<option>75</option>
<option>76</option>
<option>77</option>
<option>78</option>
<option>79</option>
<option>80</option>
<option>81</option>
<option>82</option>
<option>83</option>
<option>84</option>
<option>85</option>
<option>86</option>
<option>87</option>
<option>88</option>
<option>89</option>
<option>90</option>
<option>91</option>
<option>92</option>
<option>93</option>
<option>94</option>
<option>95</option>
<option>96</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>100</option>
</select>
<h4>Select your Mid-Term Score:</h4>
<form method = "post" action = "form3.php">
<select name = "Mid-Term">
<option>not done yet / excused</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
<option>53</option>
<option>54</option>
<option>55</option>
<option>56</option>
<option>57</option>
<option>58</option>
<option>59</option>
<option>60</option>
<option>61</option>
<option>62</option>
<option>63</option>
<option>64</option>
<option>65</option>
<option>66</option>
<option>67</option>
<option>68</option>
<option>69</option>
<option>70</option>
<option>71</option>
<option>72</option>
<option>73</option>
<option>74</option>
<option>75</option>
<option>76</option>
<option>77</option>
<option>78</option>
<option>79</option>
<option>80</option>
<option>81</option>
<option>82</option>
<option>83</option>
<option>84</option>
<option>85</option>
<option>86</option>
<option>87</option>
<option>88</option>
<option>89</option>
<option>90</option>
<option>91</option>
<option>92</option>
<option>93</option>
<option>94</option>
<option>95</option>
<option>96</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>100</option>
</select>
<h4>Select your Quiz 2 Score:</h4>
<form method = "post" action = "form3.php">
<select name = "Quiz2">
<option>not done yet / excused</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
<option>53</option>
<option>54</option>
<option>55</option>
<option>56</option>
<option>57</option>
<option>58</option>
<option>59</option>
<option>60</option>
<option>61</option>
<option>62</option>
<option>63</option>
<option>64</option>
<option>65</option>
<option>66</option>
<option>67</option>
<option>68</option>
<option>69</option>
<option>70</option>
<option>71</option>
<option>72</option>
<option>73</option>
<option>74</option>
<option>75</option>
<option>76</option>
<option>77</option>
<option>78</option>
<option>79</option>
<option>80</option>
<option>81</option>
<option>82</option>
<option>83</option>
<option>84</option>
<option>85</option>
<option>86</option>
<option>87</option>
<option>88</option>
<option>89</option>
<option>90</option>
<option>91</option>
<option>92</option>
<option>93</option>
<option>94</option>
<option>95</option>
<option>96</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>100</option>
</select>
<h4>Select your Accessed Lab 1 Score:</h4>
<form method = "post" action = "form3.php">
<select name = "AL1">
<option>not done yet / excused</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
<option>53</option>
<option>54</option>
<option>55</option>
<option>56</option>
<option>57</option>
<option>58</option>
<option>59</option>
<option>60</option>
<option>61</option>
<option>62</option>
<option>63</option>
<option>64</option>
<option>65</option>
<option>66</option>
<option>67</option>
<option>68</option>
<option>69</option>
<option>70</option>
<option>71</option>
<option>72</option>
<option>73</option>
<option>74</option>
<option>75</option>
<option>76</option>
<option>77</option>
<option>78</option>
<option>79</option>
<option>80</option>
<option>81</option>
<option>82</option>
<option>83</option>
<option>84</option>
<option>85</option>
<option>86</option>
<option>87</option>
<option>88</option>
<option>89</option>
<option>90</option>
<option>91</option>
<option>92</option>
<option>93</option>
<option>94</option>
<option>95</option>
<option>96</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>100</option>
</select>
<h4>Select your Accessed Lab 2 Score:</h4>
<form method = "post" action = "form3.php">
<select name = "AL2">
<option>not done yet / excused</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
<option>53</option>
<option>54</option>
<option>55</option>
<option>56</option>
<option>57</option>
<option>58</option>
<option>59</option>
<option>60</option>
<option>61</option>
<option>62</option>
<option>63</option>
<option>64</option>
<option>65</option>
<option>66</option>
<option>67</option>
<option>68</option>
<option>69</option>
<option>70</option>
<option>71</option>
<option>72</option>
<option>73</option>
<option>74</option>
<option>75</option>
<option>76</option>
<option>77</option>
<option>78</option>
<option>79</option>
<option>80</option>
<option>81</option>
<option>82</option>
<option>83</option>
<option>84</option>
<option>85</option>
<option>86</option>
<option>87</option>
<option>88</option>
<option>89</option>
<option>90</option>
<option>91</option>
<option>92</option>
<option>93</option>
<option>94</option>
<option>95</option>
<option>96</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>100</option>
</select>
<h4>Select your Participation Score:</h4>
<form method = "post" action = "form3.php">
<select name = "Participation">
<option>not done yet / excused</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
<option>53</option>
<option>54</option>
<option>55</option>
<option>56</option>
<option>57</option>
<option>58</option>
<option>59</option>
<option>60</option>
<option>61</option>
<option>62</option>
<option>63</option>
<option>64</option>
<option>65</option>
<option>66</option>
<option>67</option>
<option>68</option>
<option>69</option>
<option>70</option>
<option>71</option>
<option>72</option>
<option>73</option>
<option>74</option>
<option>75</option>
<option>76</option>
<option>77</option>
<option>78</option>
<option>79</option>
<option>80</option>
<option>81</option>
<option>82</option>
<option>83</option>
<option>84</option>
<option>85</option>
<option>86</option>
<option>87</option>
<option>88</option>
<option>89</option>
<option>90</option>
<option>91</option>
<option>92</option>
<option>93</option>
<option>94</option>
<option>95</option>
<option>96</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>100</option>
</select>
<h4>Select your Predicted Einal Exam score:</h4>
<form method = "post" action = "form3.php">
<select name = "Final">
<option>not done yet / excused</option>
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>6</option>
<option>7</option>
<option>8</option>
<option>9</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
<option>32</option>
<option>33</option>
<option>34</option>
<option>35</option>
<option>36</option>
<option>37</option>
<option>38</option>
<option>39</option>
<option>40</option>
<option>41</option>
<option>42</option>
<option>43</option>
<option>44</option>
<option>45</option>
<option>46</option>
<option>47</option>
<option>48</option>
<option>49</option>
<option>50</option>
<option>51</option>
<option>52</option>
<option>53</option>
<option>54</option>
<option>55</option>
<option>56</option>
<option>57</option>
<option>58</option>
<option>59</option>
<option>60</option>
<option>61</option>
<option>62</option>
<option>63</option>
<option>64</option>
<option>65</option>
<option>66</option>
<option>67</option>
<option>68</option>
<option>69</option>
<option>70</option>
<option>71</option>
<option>72</option>
<option>73</option>
<option>74</option>
<option>75</option>
<option>76</option>
<option>77</option>
<option>78</option>
<option>79</option>
<option>80</option>
<option>81</option>
<option>82</option>
<option>83</option>
<option>84</option>
<option>85</option>
<option>86</option>
<option>87</option>
<option>88</option>
<option>89</option>
<option>90</option>
<option>91</option>
<option>92</option>
<option>93</option>
<option>94</option>
<option>95</option>
<option>96</option>
<option>97</option>
<option>98</option>
<option>99</option>
<option>100</option>
</select>
<br />
<br/>
<input type = "Submit" value = "Calculate Final Grade" 
</body>
</html>

Thanks....

your html elements lacks some attribute in ur drop down...

take a cue here:

<form method="post" action="validate.php">

<select name="quiz">

<option value="-1">Select whatever applies</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>

</select>
</form>

[
// my php code to pick user select will take this form 

//Code in file........validate.php

 
$score = $_POST["quiz"] ; 
//you may want to cast to integer i.e  (int) $score 
//......code continues   as you want..

Goodluck!

Member Avatar for diafol

@Jintu

That's strange, becos it does not work properly with mine, it keeps calculating everything at 100%....Below is my html code:

That's because my setup had hard-coded $_POST variables at the top of the script. If you changed these to different percentages, you'd find the script works. That's why I mentioned that the problem was probably down to a problem with your form (rather than the script).

Hakimkal is right - you don't have any ids set for the select widget so all your $_POST variables (coming from the form) will not have a value - effectively creating 100% in your original script.

Just a bit of advice: forget hard-coding option values - use a php loop like so:

<?php
//do this at the head of the document - it can be re-used for each select dropdown.
$counter = 1;
$opt_output = "<option id=\"-1\" selected=\"selected\">not done yet / excused</option>";
while($counter <= 100){
   $opt_output .= "\n<option id=\"{$counter}\">{$counter}</option>";
   $counter = $counter + 1;
}
?>

...(html code)...

<select id="AL1" name="AL1">
   <?php echo $opt_output;?>
</select>

...(html code)...

<select id="AL2" name="AL2">
   <?php echo $opt_output;?>
</select>

...(etc)...

I don't know what you think of this, but what about putting all your dropdowns into one form? You seem to have a lot of 'open' form tags and no 'close' form tags, but only one submit button.

<form ...(attributes)...>
   ...(all your dropdowns with labels etc)...
   <input type="submit" id="submitMe" name="submitMe" value="Calculate Final Grade" />
</form>

Hope this helps.

@Jintu

That's because my setup had hard-coded $_POST variables at the top of the script. If you changed these to different percentages, you'd find the script works. That's why I mentioned that the problem was probably down to a problem with your form (rather than the script).

Hakimkal is right - you don't have any ids set for the select widget so all your $_POST variables (coming from the form) will not have a value - effectively creating 100% in your original script.

Just a bit of advice: forget hard-coding option values - use a php loop like so:

<?php
//do this at the head of the document - it can be re-used for each select dropdown.
$counter = 1;
$opt_output = "<option id=\"-1\" selected=\"selected\">not done yet / excused</option>";
while($counter <= 100){
   $opt_output .= "\n<option id=\"{$counter}\">{$counter}</option>";
   $counter = $counter + 1;
}
?>

...(html code)...

<select id="AL1" name="AL1">
   <?php echo $opt_output;?>
</select>

...(html code)...

<select id="AL2" name="AL2">
   <?php echo $opt_output;?>
</select>

...(etc)...

I don't know what you think of this, but what about putting all your dropdowns into one form? You seem to have a lot of 'open' form tags and no 'close' form tags, but only one submit button.

<form ...(attributes)...>
   ...(all your dropdowns with labels etc)...
   <input type="submit" id="submitMe" name="submitMe" value="Calculate Final Grade" />
</form>

Hope this helps.

Hello,

I have actually just started using php for the last 3 weeks, as such, I am not really familiar with all the syntax and some of the stuff that you advised me on, I am unable to comprehend it, is there a way to solve using my program code that I first displayed because we have not learn stuff like function, array, etc in class yet....

Thanks

Member Avatar for diafol

Hope this is basic enough:

DO this for every option tag so that id is equal to number displayed.

<option id="1">1</option>

etc etc

leave out the hard-coded variables (e.g. $_POST = 100) I put in my first example.

Hope this is basic enough:

DO this for every option tag so that id is equal to number displayed.

<option id="1">1</option>

etc etc

leave out the hard-coded variables (e.g. $_POST = 100) I put in my first example.

Hi,

Actually I changed all the option value of "not entered yet / excused" to -1 and it calculates as 96.45 but in my prof gradebook, it calculates as 91.5, seems strange, the php code is the same, only the html i altered it to -1 for the option not entered yet / excused" to -1, what she wants us to do is for the program to calculated based on whatever % of the course the student has taken so far, for e.g, if they have taken 60% of the stuff and they got 55, it must calculate it to be 91.6%.....Pls help, sorry to trouble u

Member Avatar for diafol

You've already done this in the script - if between 0 and 100 (inclusive) set the percentage and multiply by a scaling factor (0.05, 0.40 etc), otherwise give 100% (add 5, 40 etc).
If you return a value of '-1' in your post variable, you'll get 100%.

It's your html that's wrong. The script (well my version of it, anyhow, works perfectly). Sling up your modified version of the html so we can see it. Also show your script - there's probably a typo somewhere.

//Any news about the boat trip??

You've already done this in the script - if between 0 and 100 (inclusive) set the percentage and multiply by a scaling factor (0.05, 0.40 etc), otherwise give 100% (add 5, 40 etc).
If you return a value of '-1' in your post variable, you'll get 100%.

It's your html that's wrong. The script (well my version of it, anyhow, works perfectly). Sling up your modified version of the html so we can see it. Also show your script - there's probably a typo somewhere.

//Any news about the boat trip??

Sure, boat cruise announcement will come soon.....

My html code:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title> Grade Calculator</title>
</head>
<body>
<h1>CSCI 110 Grade Calculator</h1>
<hr />
<h4>Select your Quiz 1 Score: </h4>
<form method = "post" action = "form3.php">
<select name = "Quiz1">
<option value="-1">not done yet/excused</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
<option value="71">71</option>
<option value="72">72</option>
<option value="73">73</option>
<option value="74">74</option>
<option value="75">75</option>
<option value="76">76</option>
<option value="77">77</option>
<option value="78">78</option>
<option value="79">79</option>
<option value="80">80</option>
<option value="81">81</option>
<option value="82">82</option>
<option value="83">83</option>
<option value="84">84</option>
<option value="85">85</option>
<option value="86">86</option>
<option value="87">87</option>
<option value="88">88</option>
<option value="89">89</option>
<option value="90">90</option>
<option value="91">91</option>
<option value="92">92</option>
<option value="93">93</option>
<option value="94">94</option>
<option value="95">95</option>
<option value="96">96</option>
<option value="97">97</option>
<option value="98">98</option>
<option value="99">99</option>
<option value="100">100</option>
</select>
<h4>Select your Mid-Term Score:</h4>
<form method = "post" action = "form3.php">
<select name = "Mid-Term">
<option value="-1">not done yet/excused</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
<option value="71">71</option>
<option value="72">72</option>
<option value="73">73</option>
<option value="74">74</option>
<option value="75">75</option>
<option value="76">76</option>
<option value="77">77</option>
<option value="78">78</option>
<option value="79">79</option>
<option value="80">80</option>
<option value="81">81</option>
<option value="82">82</option>
<option value="83">83</option>
<option value="84">84</option>
<option value="85">85</option>
<option value="86">86</option>
<option value="87">87</option>
<option value="88">88</option>
<option value="89">89</option>
<option value="90">90</option>
<option value="91">91</option>
<option value="92">92</option>
<option value="93">93</option>
<option value="94">94</option>
<option value="95">95</option>
<option value="96">96</option>
<option value="97">97</option>
<option value="98">98</option>
<option value="99">99</option>
<option value="100">100</option>
</select>
<h4>Select your Quiz 2 Score:</h4>
<form method = "post" action = "form3.php">
<select name = "Quiz2">
<option value="-1">not done yet/excused</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
<option value="71">71</option>
<option value="72">72</option>
<option value="73">73</option>
<option value="74">74</option>
<option value="75">75</option>
<option value="76">76</option>
<option value="77">77</option>
<option value="78">78</option>
<option value="79">79</option>
<option value="80">80</option>
<option value="81">81</option>
<option value="82">82</option>
<option value="83">83</option>
<option value="84">84</option>
<option value="85">85</option>
<option value="86">86</option>
<option value="87">87</option>
<option value="88">88</option>
<option value="89">89</option>
<option value="90">90</option>
<option value="91">91</option>
<option value="92">92</option>
<option value="93">93</option>
<option value="94">94</option>
<option value="95">95</option>
<option value="96">96</option>
<option value="97">97</option>
<option value="98">98</option>
<option value="99">99</option>
<option value="100">100</option>
</select>
<h4>Select your Accessed Lab 1 Score:</h4>
<form method = "post" action = "form3.php">
<select name = "AL1">
<option value="-1">not done yet/excused</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
<option value="71">71</option>
<option value="72">72</option>
<option value="73">73</option>
<option value="74">74</option>
<option value="75">75</option>
<option value="76">76</option>
<option value="77">77</option>
<option value="78">78</option>
<option value="79">79</option>
<option value="80">80</option>
<option value="81">81</option>
<option value="82">82</option>
<option value="83">83</option>
<option value="84">84</option>
<option value="85">85</option>
<option value="86">86</option>
<option value="87">87</option>
<option value="88">88</option>
<option value="89">89</option>
<option value="90">90</option>
<option value="91">91</option>
<option value="92">92</option>
<option value="93">93</option>
<option value="94">94</option>
<option value="95">95</option>
<option value="96">96</option>
<option value="97">97</option>
<option value="98">98</option>
<option value="99">99</option>
<option value="100">100</option>
</select>
<h4>Select your Accessed Lab 2 Score:</h4>
<form method = "post" action = "form3.php">
<select name = "AL2">
<option value="-1">not done yet/excused</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
<option value="71">71</option>
<option value="72">72</option>
<option value="73">73</option>
<option value="74">74</option>
<option value="75">75</option>
<option value="76">76</option>
<option value="77">77</option>
<option value="78">78</option>
<option value="79">79</option>
<option value="80">80</option>
<option value="81">81</option>
<option value="82">82</option>
<option value="83">83</option>
<option value="84">84</option>
<option value="85">85</option>
<option value="86">86</option>
<option value="87">87</option>
<option value="88">88</option>
<option value="89">89</option>
<option value="90">90</option>
<option value="91">91</option>
<option value="92">92</option>
<option value="93">93</option>
<option value="94">94</option>
<option value="95">95</option>
<option value="96">96</option>
<option value="97">97</option>
<option value="98">98</option>
<option value="99">99</option>
<option value="100">100</option>
</select>
<h4>Select your Participation Score:</h4>
<form method = "post" action = "form3.php">
<select name = "Participation">
<option value="-1">not done yet/excused</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
<option value="71">71</option>
<option value="72">72</option>
<option value="73">73</option>
<option value="74">74</option>
<option value="75">75</option>
<option value="76">76</option>
<option value="77">77</option>
<option value="78">78</option>
<option value="79">79</option>
<option value="80">80</option>
<option value="81">81</option>
<option value="82">82</option>
<option value="83">83</option>
<option value="84">84</option>
<option value="85">85</option>
<option value="86">86</option>
<option value="87">87</option>
<option value="88">88</option>
<option value="89">89</option>
<option value="90">90</option>
<option value="91">91</option>
<option value="92">92</option>
<option value="93">93</option>
<option value="94">94</option>
<option value="95">95</option>
<option value="96">96</option>
<option value="97">97</option>
<option value="98">98</option>
<option value="99">99</option>
<option value="100">100</option>
</select>
<h4>Select your Predicted Einal Exam score:</h4>
<form method = "post" action = "form3.php">
<select name = "Final">
<option value="-1">not done yet/excused</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
<option value="32">32</option>
<option value="33">33</option>
<option value="34">34</option>
<option value="35">35</option>
<option value="36">36</option>
<option value="37">37</option>
<option value="38">38</option>
<option value="39">39</option>
<option value="40">40</option>
<option value="41">41</option>
<option value="42">42</option>
<option value="43">43</option>
<option value="44">44</option>
<option value="45">45</option>
<option value="46">46</option>
<option value="47">47</option>
<option value="48">48</option>
<option value="49">49</option>
<option value="50">50</option>
<option value="51">51</option>
<option value="52">52</option>
<option value="53">53</option>
<option value="54">54</option>
<option value="55">55</option>
<option value="56">56</option>
<option value="57">57</option>
<option value="58">58</option>
<option value="59">59</option>
<option value="60">60</option>
<option value="61">61</option>
<option value="62">62</option>
<option value="63">63</option>
<option value="64">64</option>
<option value="65">65</option>
<option value="66">66</option>
<option value="67">67</option>
<option value="68">68</option>
<option value="69">69</option>
<option value="70">70</option>
<option value="71">71</option>
<option value="72">72</option>
<option value="73">73</option>
<option value="74">74</option>
<option value="75">75</option>
<option value="76">76</option>
<option value="77">77</option>
<option value="78">78</option>
<option value="79">79</option>
<option value="80">80</option>
<option value="81">81</option>
<option value="82">82</option>
<option value="83">83</option>
<option value="84">84</option>
<option value="85">85</option>
<option value="86">86</option>
<option value="87">87</option>
<option value="88">88</option>
<option value="89">89</option>
<option value="90">90</option>
<option value="91">91</option>
<option value="92">92</option>
<option value="93">93</option>
<option value="94">94</option>
<option value="95">95</option>
<option value="96">96</option>
<option value="97">97</option>
<option value="98">98</option>
<option value="99">99</option>
<option value="100">100</option>
</select>
<br />
<br/>
<input type = "Submit" value = "Calculate My Grade" 
</body>
</html>

My Php Script Code:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title>Grade Calculator</title>
</head>
<body>
<?php
$grade=0;
if ($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100)
	$grade = $grade + $_POST['Quiz1'] * 0.05;
else
  	$grade = $grade + 5; 
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
	$grade = $grade + $_POST['Mid-Term'] * 0.30;
else
  	$grade = $grade + 30; 
if ($_POST['Quiz2'] >= 0 && ($_POST['Quiz2'] <= 100))
	$grade = $grade + $_POST['Quiz2'] * 0.05;
else
  	$grade = $grade + 5; 
if ($_POST['AL1'] >= 0 && ($_POST['AL1'] <= 100))
	$grade = $grade + $_POST['AL1'] * 0.05;
else
   	$grade = $grade + 5; 
if ($_POST['AL2'] >= 0 && ($_POST['AL2'] <= 100))
	$grade = $grade + $_POST['AL2'] * 0.05;
else
  	$grade = $grade + 5; 
if ($_POST['Participation'] >= 0 && ($_POST['Participation'] <= 100))
	$grade = $grade + $_POST['Participation'] * 0.10;
else
 	$grade = $grade + 10; 
if ($_POST['Final'] >= 0 && ($_POST['Final'] <= 100))
	$grade = $grade + $_POST['Final'] * 0.40;
else
  	$grade = $grade + 40;	

?>
<?php
echo "Grade Report: <br />";
echo "<br />";
?>
Your final grade percentage will be:  <?php echo $grade. "%";
echo "<br />";
{
if ($grade > 90.9)
	echo "Your final grade for the course will be: A+ <br />";
elseif ($grade > 85.9)
	echo "Your final grade for the course will be: A  <br />";
elseif ($grade > 79)
	echo "Your final grade for the course will be: A-  <br />";
elseif ($grade > 76.9)
	echo "Your final grade for the course will be: B+  <br />";
elseif ($grade >71.9)
	echo "Your final grade for the course will be: B  <br />";
elseif ($grade > 69.9)
	echo "Your final grade for the course will be: B-  <br />";
elseif ($grade > 65.9)
	echo "Your final grade for the course will be: C+  <br />";
elseif ($grade > 59.9)
	echo "Your final grade for the course will be: C  <br />";
elseif ($grade > 54.9)
	echo "Your final grade for the course will be: C-  <br />";
elseif ($grade > 49.9)
	echo "Your final grade for the course will be: P  <br />";
else
	echo "Your final grade for the course will be: F  <br />";

}

?>
</body>
</html>

Thanks a million....

Member Avatar for diafol

Here's a fix, couldn't see how to fix your problem without re-writing the form and twiddling the script:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title>Grade Calculator</title>
<style>
	label{
		float:left;width:200px;
	}
</style>

</head>
<body>
<?php
/*QUICK TEST VARIABLES 
Just use these for script debugging
$_POST['Quiz1'] = '100';
$_POST['Quiz2'] = '100';
$_POST['Mid-Term'] = '100';
$_POST['AL1'] = '100';
$_POST['AL2'] = '100';
$_POST['Participation'] = '100';
$_POST['Final'] = '100';
*/

if(isset($_POST['submit'])){ //IF FORM SENT
	//default answer will be 0%
	$grade=0;
	//calculate $grade percentage from form input (or from quick test variables)
	$grade=($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100) ? $grade + ($_POST['Quiz1'] * 0.05) : $grade + 5; 
	$grade=($_POST['Mid-Term'] >= 0 && $_POST['Mid-Term'] <= 100) ? $grade + ($_POST['Mid-Term'] * 0.30) : $grade + 30; 
	$grade=($_POST['Quiz2'] >= 0 && $_POST['Quiz2'] <= 100) ? $grade + ($_POST['Quiz2'] * 0.05) : $grade + 5;
	$grade=($_POST['AL1'] >= 0 && $_POST['AL1'] <= 100) ? $grade + ($_POST['AL1'] * 0.05) : $grade + 5; 
	$grade=($_POST['AL2'] >= 0 && $_POST['AL2'] <= 100) ? $grade + ($_POST['AL2'] * 0.05) : $grade + 5; 
	$grade=($_POST['Participation'] >= 0 && $_POST['Participation'] <= 100) ? $grade + ($_POST['Participation'] * 0.10) : $grade + 10; 
	$grade=($_POST['Final'] >= 0 && $_POST['Final'] <= 100) ? $grade + ($_POST['Final'] * 0.40) : $grade + 40; 
	
	//change these as you need
	$pc_array= array(90.9,85.9,79,76.9,71.9,69.9,65.9,59.9,54.9,49.9);
	$grade_array=array('A+','A','A-','B+','B','B-','C+','C','C-','P');
	$i = 0;
	//default answer will be FAIL
	$print_grade = 'F';
	while($i < count($pc_array)){
		if($grade > $pc_array[$i]){
			$print_grade = $grade_array[$i];
			break;
		}
		$i = $i + 1;
	}
	
	// output
	echo "<h1>Grade Report: </h1>\n<p>Your final grade percentage will be: {$grade}%</p>\n<p>Your final grade for the course will be: {$print_grade}</p>";
} //END IF FORM SENT


//this can be re-used for each select dropdown.
//however, if you want to display the used values in the form after form sent, you'll need something a little more sophisticated, that'll put a 'selected="selected"' next to the option.
$counter = 1;
$opt_output = "<option value=\"-1\">not done yet / excused</option>";
while($counter <= 100){
   $opt_output .= "\n<option value=\"{$counter}\">{$counter}</option>";
   $counter = $counter + 1;
}
?>

<h1>CSCI 110 Grade Calculator</h1>
<hr />
<p>Select your Scores</p>

<form method = "post" action = "<?php echo $_SERVER['PHP_SELF'];?>">
        <label>Quiz 1:</label>	
        <select name = "Quiz1">
		<?php echo $opt_output;?>

	</select><br />
	<label>Mid-Term:</label>
	<select name = "Mid-Term">
		<?php echo $opt_output;?>

	</select><br />
	<label>Quiz 2:</label>
	<select name = "Quiz2">
		<?php echo $opt_output;?>

	</select><br />
	<label>Accessed Lab 1:</label>
	<select name = "AL1">
		<?php echo $opt_output;?>

	</select><br />
	<label>Accessed Lab 2:</label>
	<select name = "AL2">
		<?php echo $opt_output;?>

	</select><br />
	<label>Participation:</label>
	<select name = "Participation">
		<?php echo $opt_output;?>

	</select><br />
	<label>Predicted Einal Exam:</label>
	<select name = "Final">
		<?php echo $opt_output;?>

	</select>
	<br />
	<br/>
	<input name="submit" id="submit" type = "Submit" value = "Calculate Final Grade" />
</form>
</body>
</html>

Don't use it as is, have a play with it and see how to modify it to your needs.

Here's a fix, couldn't see how to fix your problem without re-writing the form and twiddling the script:

<html>
<head>
<link rel="stylesheet" type="text/css" href="http://96.48.39.33/student13/bala2.css" />
<title>Grade Calculator</title>
<style>
	label{
		float:left;width:200px;
	}
</style>

</head>
<body>
<?php
/*QUICK TEST VARIABLES 
Just use these for script debugging
$_POST['Quiz1'] = '100';
$_POST['Quiz2'] = '100';
$_POST['Mid-Term'] = '100';
$_POST['AL1'] = '100';
$_POST['AL2'] = '100';
$_POST['Participation'] = '100';
$_POST['Final'] = '100';
*/

if(isset($_POST['submit'])){ //IF FORM SENT
	//default answer will be 0%
	$grade=0;
	//calculate $grade percentage from form input (or from quick test variables)
	$grade=($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100) ? $grade + ($_POST['Quiz1'] * 0.05) : $grade + 5; 
	$grade=($_POST['Mid-Term'] >= 0 && $_POST['Mid-Term'] <= 100) ? $grade + ($_POST['Mid-Term'] * 0.30) : $grade + 30; 
	$grade=($_POST['Quiz2'] >= 0 && $_POST['Quiz2'] <= 100) ? $grade + ($_POST['Quiz2'] * 0.05) : $grade + 5;
	$grade=($_POST['AL1'] >= 0 && $_POST['AL1'] <= 100) ? $grade + ($_POST['AL1'] * 0.05) : $grade + 5; 
	$grade=($_POST['AL2'] >= 0 && $_POST['AL2'] <= 100) ? $grade + ($_POST['AL2'] * 0.05) : $grade + 5; 
	$grade=($_POST['Participation'] >= 0 && $_POST['Participation'] <= 100) ? $grade + ($_POST['Participation'] * 0.10) : $grade + 10; 
	$grade=($_POST['Final'] >= 0 && $_POST['Final'] <= 100) ? $grade + ($_POST['Final'] * 0.40) : $grade + 40; 
	
	//change these as you need
	$pc_array= array(90.9,85.9,79,76.9,71.9,69.9,65.9,59.9,54.9,49.9);
	$grade_array=array('A+','A','A-','B+','B','B-','C+','C','C-','P');
	$i = 0;
	//default answer will be FAIL
	$print_grade = 'F';
	while($i < count($pc_array)){
		if($grade > $pc_array[$i]){
			$print_grade = $grade_array[$i];
			break;
		}
		$i = $i + 1;
	}
	
	// output
	echo "<h1>Grade Report: </h1>\n<p>Your final grade percentage will be: {$grade}%</p>\n<p>Your final grade for the course will be: {$print_grade}</p>";
} //END IF FORM SENT


//this can be re-used for each select dropdown.
//however, if you want to display the used values in the form after form sent, you'll need something a little more sophisticated, that'll put a 'selected="selected"' next to the option.
$counter = 1;
$opt_output = "<option value=\"-1\">not done yet / excused</option>";
while($counter <= 100){
   $opt_output .= "\n<option value=\"{$counter}\">{$counter}</option>";
   $counter = $counter + 1;
}
?>

<h1>CSCI 110 Grade Calculator</h1>
<hr />
<p>Select your Scores</p>

<form method = "post" action = "<?php echo $_SERVER['PHP_SELF'];?>">
        <label>Quiz 1:</label>	
        <select name = "Quiz1">
		<?php echo $opt_output;?>

	</select><br />
	<label>Mid-Term:</label>
	<select name = "Mid-Term">
		<?php echo $opt_output;?>

	</select><br />
	<label>Quiz 2:</label>
	<select name = "Quiz2">
		<?php echo $opt_output;?>

	</select><br />
	<label>Accessed Lab 1:</label>
	<select name = "AL1">
		<?php echo $opt_output;?>

	</select><br />
	<label>Accessed Lab 2:</label>
	<select name = "AL2">
		<?php echo $opt_output;?>

	</select><br />
	<label>Participation:</label>
	<select name = "Participation">
		<?php echo $opt_output;?>

	</select><br />
	<label>Predicted Einal Exam:</label>
	<select name = "Final">
		<?php echo $opt_output;?>

	</select>
	<br />
	<br/>
	<input name="submit" id="submit" type = "Submit" value = "Calculate Final Grade" />
</form>
</body>
</html>

Don't use it as is, have a play with it and see how to modify it to your needs.

It works, but the problem is: for scores of quiz1 - 97, mid-term - 95, quiz2 - 93, Accessed Lab 1 - 69, Participation -100, so not including accessed lab 2 and final, this program calculates it as 96.45% but in my prof's gradebook, it calculates as 91.5%........

Member Avatar for diafol

It works, but the problem is: for scores of quiz1 - 97, mid-term - 95, quiz2 - 93, Accessed Lab 1 - 69, Participation -100, so not including accessed lab 2 and final, this program calculates it as 96.45% but in my prof's gradebook, it calculates as 91.5%........

Sorry to say but I think your prof is wrong.
0.05*97 + 95*0.3 + 93*0.05 + 69*0.05 + 100*0.05 + 100*0.1 + 100*0.4 = 96.45
I checked it in Excel just to be sure. It seems as though your prof has approx 5% discrepancy (probably one of the 5% items is missing - the AL2?).

Sorry to say but I think your prof is wrong.
0.05*97 + 95*0.3 + 93*0.05 + 69*0.05 + 100*0.05 + 100*0.1 + 100*0.4 = 96.45
I checked it in Excel just to be sure. It seems as though your prof has approx 5% discrepancy (probably one of the 5% items is missing - the AL2?).

Thank you so much for your help all this while, you have been extremely patient, appreciate it, I will double check with my prof on tuesday and confirm it, will let you know the outcome after she explains....

Thanks again....

Sorry to say but I think your prof is wrong.
0.05*97 + 95*0.3 + 93*0.05 + 69*0.05 + 100*0.05 + 100*0.1 + 100*0.4 = 96.45
I checked it in Excel just to be sure. It seems as though your prof has approx 5% discrepancy (probably one of the 5% items is missing - the AL2?).

Hello,

I just spoke my prof, she said that for the option of "not done yet / excused", it cannot include the percentile of the whatever the component, for example, if the person has only done quiz 1 and everything else is "not done yet / excused" , it must be able to calculate it is, for example 80%, it must show as just 80% even though everything else is "not done yet / excused", when i asked her if there any special syntax, method to achieve this, she simply said, "it's logic", what do u think, please advise how to achieve this?

Thanks

Tony

Member Avatar for diafol

Well, this isn't what you stated in your original postr, you said that if something hasn't been completed yet that it counted as 100%. You've moved the goalposts. OK I'll give you a few pointers in a few minutes.

Well, this isn't what you stated in your original postr, you said that if something hasn't been completed yet that it counted as 100%. You've moved the goalposts. OK I'll give you a few pointers in a few minutes.

Thanks, because, I thought, that was the purpose of the program, till today, when I clarified with her, then I found out that whatever that i was doing was wrong, thanks again...

Hi there,
I would use the if/else approach originally suggested without adding the full mark for an uninitialised POST variable. Additionally keep track of how much each of the tests is supposed to count (eg If you would multiply a mark by 0.05 to form part of the final mark, increment a variable, at the same time you add that variable to the grade, by that 0.05 ) So that in the end, you have your Grade Mark out of 100 and your other (counter) variable which has the ratio of completed assignments to 1. Then you can take your Grade mark and work it out as a percentage relative to 100 * counter variable.

Sorry if that seems a little convoluted, i'll try knock together a code snippet to explain it better.

Hi there,
I would use the if/else approach originally suggested without adding the full mark for an uninitialised POST variable. Additionally keep track of how much each of the tests is supposed to count (eg If you would multiply a mark by 0.05 to form part of the final mark, increment a variable, at the same time you add that variable to the grade, by that 0.05 ) So that in the end, you have your Grade Mark out of 100 and your other (counter) variable which has the ratio of completed assignments to 1. Then you can take your Grade mark and work it out as a percentage relative to 100 * counter variable.

Sorry if that seems a little convoluted, i'll try knock together a code snippet to explain it better.

It seems a bit confusing, would appreciate if you explain it using codes, thanks a million.

Tony

Heres what I meant (in code)

$grade = 0;
$grade_out_of = 0;
if ($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100)
{
    $grade = $grade + $_POST['Quiz1'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
{
    $grade = $grade + $_POST['Mid-Term'] * 0.30;
    $grade_out_of = $grade_out_of + 0.30;
}
if ($_POST['Quiz2'] >= 0 && ($_POST['Quiz2'] <= 100))
{
    $grade = $grade + $_POST['Quiz2'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['AL1'] >= 0 && ($_POST['AL1'] <= 100))
{
    $grade = $grade + $_POST['AL1'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['AL2'] >= 0 && ($_POST['AL2'] <= 100))
{
    $grade = $grade + $_POST['AL2'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['Participation'] >= 0 && ($_POST['Participation'] <= 100))
{
    $grade = $grade + $_POST['Participation'] * 0.10;
    $grade_out_of = $grade_out_of + 0.10;
}
if ($_POST['Final'] >= 0 && ($_POST['Final'] <= 100))
{
    $grade = $grade + $_POST['Final'] * 0.40;
    $grade_out_of = $grade_out_of + 0.40;
}
//Now right here, your grade looks like something out of 100
//But is is really only out of: 100 * $grade_out_of
//Therefore, your final grade is:
$grade = floatval($grade / ($grade_out_of * 100));
Member Avatar for diafol

I can't see where the 91.5% comes from, I got 92.1% from the new info you've supplied:

For example (first 4 tests taken -> max total scaling = 45 (5+30+5+5))

Quiz1 = 97% x 5/45 (scaling/total scaling) = 10.77777778
Mid-Term = 95% x 30/45 = 63.33333333
Quiz2 = 93% x 5/45 = 10.33333333
AL1 = 69% x 5/45 = 7.666666667

Grand total = 92.1%

It may be my method that crack'd and bust, but I honestly don't see which other way she is calculating this. I have a script that calculates via the methodology above if you're interested, but check the logic first. How on earth is she getting 91.5%??

I can't see where the 91.5% comes from, I got 92.1% from the new info you've supplied:

For example (first 4 tests taken -> max total scaling = 45 (5+30+5+5))

Quiz1 = 97% x 5/45 (scaling/total scaling) = 10.77777778
Mid-Term = 95% x 30/45 = 63.33333333
Quiz2 = 93% x 5/45 = 10.33333333
AL1 = 69% x 5/45 = 7.666666667

Grand total = 92.1%

It may be my method that crack'd and bust, but I honestly don't see which other way she is calculating this. I have a script that calculates via the methodology above if you're interested, but check the logic first. How on earth is she getting 91.5%??

I cannot comprehend it too, for example, she said the participation is divided in two parts, participation 1 and 2, worth 5% each...even with that it does not add to 91.5 considering that i got 100% for participation 1..

Heres what I meant (in code)

$grade = 0;
$grade_out_of = 0;
if ($_POST['Quiz1'] >= 0 && $_POST['Quiz1'] <= 100)
{
    $grade = $grade + $_POST['Quiz1'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['Mid-Term'] >= 0 && ($_POST['Mid-Term'] <= 100))
{
    $grade = $grade + $_POST['Mid-Term'] * 0.30;
    $grade_out_of = $grade_out_of + 0.30;
}
if ($_POST['Quiz2'] >= 0 && ($_POST['Quiz2'] <= 100))
{
    $grade = $grade + $_POST['Quiz2'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['AL1'] >= 0 && ($_POST['AL1'] <= 100))
{
    $grade = $grade + $_POST['AL1'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['AL2'] >= 0 && ($_POST['AL2'] <= 100))
{
    $grade = $grade + $_POST['AL2'] * 0.05;
    $grade_out_of = $grade_out_of + 0.05;
}
if ($_POST['Participation'] >= 0 && ($_POST['Participation'] <= 100))
{
    $grade = $grade + $_POST['Participation'] * 0.10;
    $grade_out_of = $grade_out_of + 0.10;
}
if ($_POST['Final'] >= 0 && ($_POST['Final'] <= 100))
{
    $grade = $grade + $_POST['Final'] * 0.40;
    $grade_out_of = $grade_out_of + 0.40;
}
//Now right here, your grade looks like something out of 100
//But is is really only out of: 100 * $grade_out_of
//Therefore, your final grade is:
$grade = floatval($grade / ($grade_out_of * 100));

I tested with this program, it works perfectly and ardav was rite for the four components that are added up, it calculates as 92.1 and not 91.5, in my grade book it is 91.5% components are quzi 1 -97, mid-term - 95, quiz 2 -93, accessed lab -69 and participation 1 - 100%, program calculates as 92.9% but in my prof's grade book, it is 91.5, any way to explain this, please advise.... Can i raise an argument with her that her grade book calculation is wrong???

I would only advise that as a last resort, teachers don't really like to get told how it is. But if you've exhausted all other options and you are sure that nothing is being left out or accidentally added in, then go for it. I'm pretty sure she won't fail you for it. And if she does, at least she might tell you where you went wrong.

I would only advise that as a last resort, teachers don't really like to get told how it is. But if you've exhausted all other options and you are sure that nothing is being left out or accidentally added in, then go for it. I'm pretty sure she won't fail you for it. And if she does, at least she might tell you where you went wrong.

Thanks for your advice and solution...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.