i want to automatically get a grade value for each subject after calculating the sum for each total field : after i have calculated the sum i want the grade to appear automatically without clicking on any button.
    
    <tr class="row1">
    <th>Class Name</th><th>1st</th><th>2nd</th><th>3rd</th><th>Total</th><th>Grade</th>
    </tr>
    <tr class="row">
	<td>Class 1:</td>
	<td><input type="number" name="1" id="1" class='first'></td>
	<td><input type="number" name="2" id="2" class='second'></td>
	<td><input type="number" name="3" id="3" class='third'></td>
	<td><input type="text" name="4" id="4" class='total' readonly></td>
	<td><input type="text" class='demo' readonly ></td>
    </tr>

    <tr class="row">
	<td>Class 2:</td>
	<td><input type="number" name="1" id="1" class='first'></td>
	<td><input type="number" name="2" id="2" class='second'></td>
	<td><input type="number" name="3" id="3" class='third'></td>
	<td><input type="text" name="4" id="4" class='total' readonly></td>
	<td><input type="text" class='demo' readonly ></td>
    </tr>

i am having difficulty in making this javascript switch statement to work for me. pls i need help

    function myFunction()
    {
	 var num = document.getElementsByClassName("total").value;
	 switch(true)
	 {
		case (num >= 91 && num <= 100):
			document.getElementsByClassName("demo").innerHTML = "A+";;
			break;
		case (num >= 81 && num <= 90):
			document.getElementsByClassName("demo").innerHTML = "A";
			break;
		case (num >= 71 && num <= 80):
			document.getElementsByClassName("demo").innerHTML = "B+";
			break;
		case (num >= 61 && num <= 70):
			document.getElementsByClassName("demo").innerHTML = "B";
			break;
		case (num >= 51 && num <= 60):
			document.getElementsByClassName("demo").innerHTML = "C";
			break;
		case (num >= 41 && num <= 50):
			document.getElementsByClassName("demo").innerHTML = "D";
			break;
		case (num >= 31 && num <= 40):
			document.getElementsByClassName("demo").innerHTML = "E";
			break;
		case (num >= 0 && num <= 30):
			document.getElementsByClassName("demo").innerHTML = "F";
			break;
		default:
			document.getElementsByClassName("demo").innerHTML = "No grade yet";
			break;
	};
    };