cs101 assignment 3 idea solution fall 2019 2020

cs101 assignment 3 idea solution fall 2019 2020

 

<html>
<head><title>Virtual Study Solutions</title>
<script type=”text/javascript”>

function generateTable(){
var number = document.getElementById(‘number’).value;
var length = document.getElementById(‘length’).value;
if(parseInt(number) < 1 || parseInt(length) < 1){
alert(“Invalid Input!”);
return;
}

 



var tableArr = new Array();
length = parseInt(length);
number = parseInt(number);
var oddCount = 0;
var evenCount = 0;
var checkNumber;
for(var i = 1; i <= length; i++){
var calc = number + ” X ” + i + ” = ” + (number * i) + ‘\n’;
tableArr.push(calc);
checkNumber = number * i;
if(checkNumber % 2 == 0){
evenCount++;
}else{
oddCount++;
}

}

 



document.getElementById(‘even’).value = evenCount;
document.getElementById(‘odd’).value = oddCount;
document.getElementById(‘table-area’).value = tableArr.join(“”);

}
</script>
</head>
<body style=”text-align: center; background-color: #A9A9A9;” >
<h1><u>Table Genrator</u></h1>
<table border=”1″ align=”center” style=”background-color: #FFFF00;”>
<tr><td>Enter Table Number</td><td><input type=”number” id=”number”></td></tr>
<tr><td>Enter Table Length</td><td><input type=”number” id=”length”></td></tr>
</table><br>
<button id=”gen-btn” onclick=”generateTable()”>Generate</button>
<br><br>
<table border=”1″ align=”center” style=”background-color: #FFFF00;”>
<tr><td>Total Even Values</td><td><input type=”text” readonly id=”even”></td></tr>
<tr><td>Total Odd Values</td><td><input type=”text” readonly id=”odd”></td></tr>
<tr ><td colspan=”2″ align=”center”>
<textarea readonly id=”table-area” rows=”20″ cols=”38″ placeholder=”Table output will be displayed here.”></textarea>
</td></tr>
</table>

</body>
</html>

You May Also Like

One thought on “cs101 assignment 3 idea solution fall 2019 2020

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: