Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE HELP WITH JAVASCRIPT: FILL IN SKELETON CODE Here is the skeleton code: <h

ID: 3844792 • Letter: P

Question

PLEASE HELP WITH JAVASCRIPT: FILL IN SKELETON CODE

Here is the skeleton code:

<html class="gr__content_sakai_rutgers_edu"><head>
<!--
Student:Alyxes Nguyen
NetID:169002633
Section:22
TA:Ajinkya
-->
</head>
  
<body data-gr-c-s-loaded="true">
  
<script>
  
/* Your code starts here */
  
function processCheck() {
/* Check all the fields are valid, otherwise just return */
  
/* Populate RANDOM check whole number between 10000 and 20000 */
  
/* Populate today's date with format mm-dd-yyyy */
  
/* Populate full name */
  
/* Populate address */
  
/* Populate dollar amount */
  
/* Populate money */
  
}

function getName() {
// complete here
}

function getAddress() {
// complete here
}
  
function calculateTotal() {
  
/* Calculate base salary yearly / 26 */
  
/* Adjust based on shift */
  
/* Discount Health Plan */
  
}

function validateFields() {
  
}

/* end of code */
  
</script>
  
<!--
********************************************************
* DONT CHANGE ANY CODE BELOW THIS POINT *
********************************************************
-->

<div id="infoForm">
<table>
<tbody><tr>
<td>
<label> First Name </label>
</td>
<td>
<label> Middle Name </label>
</td>
<td>
<label> Last Name </label>
</td>
</tr>
<tr>
<td>
<input type="text" id="firstNameBox">
</td>
<td>
<input type="text" id="middleNameBox">
</td>
<td>
<input type="text" id="lastNameBox">
</td>
</tr>
<tr>
<td colspan="2">
<label>Address</label>
</td>
<td>
<label>City</label>
</td>
</tr>
<tr>
<td colspan="2"><input type="text" id="addressBox"></td>
<td><input type="text" id="cityBox"></td>
</tr>
<tr>
<td>
<label>Zip Code</label>
</td>
<td>
<label>State</label>
</td>
<td>
<label>Employee ID</label>
</td>
</tr>
<tr>
<td>
<input type="text" id="zipBox">
</td>
<td>
<input type="text" id="stateBox">
</td>
<td>
<input type="text" id="employeeIDBox">
</td>
</tr>
<tr>
<td colspan="2"><label>Category</label></td>
<td><label>Shift</label></td>
</tr>
<tr>
<td colspan="2">
<select id="categoryIDBox">
<option>CAT A - Manufacturing</option>
<option>CAT B - Accounting</option>
<option>CAT C - Administrative</option>
<option> </option>
</select>
</td>
<td>
<select id="shiftBox">
<option>Regular</option>
<option>Night</option>
<option>Rotating</option>
</select>
</td>
</tr>
<tr>
<td colspan="3"><label>Health Plan</label></td>
</tr>
<tr>
<td id="radioRow" colspan="3">
<label>None</label>
<input type="radio" id="noneRadio" name="healthPlan" value="None" checked="checked">
<label>HMO</label>
<input type="radio" id="hmoRadio" name="healthPlan" value="HMO">
<label>PPO</label>
<input type="radio" id="ppoRadio" name="healthPlan" value="PPO">
</td>
</tr>
</tbody></table>

<div>
<button id="processBtn" type="button">Process Check</button>
</div>

</div>

<h1>Auto Paycheck</h1>
<hr>

<div id="autoCheck">
<div>
CS170 Management Group<br>
Rutgers University<br>
7 College Ave,<br>
New Brunswick, NJ 08901
</div>
<div>
<table>
<tbody><tr>
<td>Check Number</td>
<td><input class="centered" id="checkNumberBox" type="text" readonly="" placeholder="check number"></td>
</tr>
<tr>
<td>Pay Date</td>
<td><input class="centered" id="payDateBox" type="text" readonly="" placeholder="dd-mm-yyyy"></td>
</tr>
</tbody></table>
</div>
<hr>
  
<div>
<label>PAY</label>
<input type="text" id="payMoney" readonly="">
<label>$</label>
<input type="text" id="dollarAmount" readonly="">
</div>
  
<div>
<label>To the Order of:</label> <br>
<div id="orderDiv">
<input type="text" readonly="" id="orderName"> <br>
<textarea id="orderAddress" rows="2" cols="55" readonly="" resizable="false"></textarea>
</div>
</div>


</div>
  
<script>
function getValueString(val) {
  
var str = new String(val);
var cents = str.indexOf('.');
if(cents != -1) {
cents = Number(str.substring(cents+1));
}
val = Math.floor(val);
var dig = 1000;
var s = "";
while((new String(dig)).length > 2) {
if(dig < val) {
  
var v = Math.floor(val / dig);
str = new String(dig);
if(v != 0) {
switch(v) {
case 10:
s += 'ten ';
break;
case 9:
s += 'nine ';
break;
case 8:
s += 'eight ';
break;
case 7:
s += 'seven ';
break;
case 6:
s += 'six ';
break;
case 5:
s += 'five ';
break;
case 4:
s += 'four ';
break;
case 3:
s += 'three ';
break;
case 2:
s += 'two ';
break;
case 1:
s += 'one ';
}
  
if(str.length == 4) {
s += 'thousand ';
} else if(str.length == 3) {
s += 'hundred ';
}
}
val %= dig;
}
dig /= 10;
}
s += 'and ' + val + ' dollars with ' + cents + ' cents';
return s;
}
</script>
  
<style>
  
body {
min-width: 1080px;
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}
  
#infoForm {
width: 50%;
margin: auto;
margin-top: 2em;
}
  
#infoForm table {
border-collapse: separate;
border-spacing: 15px;
-webkit-box-shadow: 0 10px 6px -6px #222;
-moz-box-shadow: 0 10px 6px -6px #222;
box-shadow: 0 10px 6px -6px #222;
padding: 1em;
color: white;
background: rgb(120,120,120);
border-radius: 5px;
margin: auto;
}
  
#infoForm input[type=text], select {
border-radius: 3px;
font-size: 110%;
color: #333;
padding: 5px;
border: none;
background: rgb(170,170,170);
border-bottom: 1px solid #EEE;
width: 100%;
}
  
select {
padding: 20px;
}
  
input[type=text]:focus {
outline: 2px solid #FFF;
}
  
#radioRow {
text-align: center;
}
  
#radioRow label, #radioRow input[type=radio] {
margin: 0 2% 0 2%;
}
  
#autoCheck, h1 { margin: auto; margin-top: 1em; width: 90%; }
  
#autoCheck {
border-radius: 15px 0 15px 0;
background: #DDD;
-webkit-box-shadow: 0 10px 6px -6px #222;
-moz-box-shadow: 0 10px 6px -6px #222;
box-shadow: 0 10px 6px -6px #222;
}
  
#autoCheck input {
font-size: 90%;
padding: 2px;
}

#autoCheck input:placeholder-shown {
text-align: center;
}

.centered {
text-align: center;
}
  
#autoCheck hr {
margin: 10px;
border: 0;
height: 1px;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
}

#orderDiv input, #orderDiv textarea {
margin: 5px;
width: 40%;
}

#processBtn {
background: #CCC;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0px;
color: #333;
font-size: 18px;
padding: 10px 20px 10px 20px;
text-decoration: none;
margin-top: 20px;
}

#orderAddress {
resize: none;
border: none;
}
  
</style>
  
  

</body>

</html>

You will complete the implementation of the following functions: function processCheck0 This is the main function, the one which will be called when the button is pressed. From here you will call the other functions in order to obtain all the required information to populate the input fields. Use the given function getValueString(val) were val is a real number value. function getName() A simple function which returns the concatenation of firstname+middlename+lastname. function getAddress0 Just as getName, but it returns a single string with the following format: Address, City, State, Zip Note the break line from address to the last line. This can be achieve with the special character "In" function calculateTotal0 f... return a single value, rounded to TWO digits. You will compute the total Bl-WEEKLY (26 paychecks per year) salary based on the following rules: $55000 CAT A Manufacturing CAT B Accounting $69500 CAT C Administrative $58700 CAT D IT $73200 Night shift 10% extra Rotating 15% No Health Plan 2% discount for general deductions HMO Health Plan 9% discount PPO Health Plan 11% discount

Explanation / Answer

The code has been added and is quoted with comments as well for better understanding.

<script>
  
/* Your code starts here */
  
function processCheck() {
/* Check all the fields are valid, otherwise just return */
if(!validateFields()) return;
  
/* Populate RANDOM check whole number between 10000 and 20000 */

// gets a random number between 10000 and 20000... both inclusive...
var randomNumber = Math.floor(Math.random() * (20000 - 10000 + 1) + 10000);
document.getElementById('checkNumberBox').value = randomNumber;
  
/* Populate today's date with format mm-dd-yyyy */
var d = new Date();
var todaysDate = ("0" + d.getDate()).slice(-2) + "-" + ("0" + d.getMonth()).slice(-2) + "-" + d.getFullYear();
document.getElementById('payDateBox').value = todaysDate;
  
/* Populate full name */
document.getElementById('orderName').value = getName();
  
/* Populate address */
document.getElementById('orderAddress').value = getAddress();
  
/* Populate dollar amount */
var totalAmount = calculateTotal();
document.getElementById('dollarAmount').value = totalAmount;
  
/* Populate money */

// the method is already defined: getValueString
document.getElementById('payMoney').value = getValueString(totalAmount);
}
function getName() {
// complete here
var fullName = document.getElementById('firstNameBox').value + " ";

// add middle name only when it is present.. since it is optional.
fullName += (document.getElementById('middleNameBox').value.length > 0) ? (document.getElementById('middleNameBox').value + " ") : "";
fullName += document.getElementById('lastNameBox').value;
return fullName;
}
function getAddress() {
// complete here
return document.getElementById('addressBox').value + ", " + document.getElementById('cityBox').value + "," + document.getElementById('stateBox').value + "," + document.getElementById('zipBox').value;
}
  
function calculateTotal() {
  
/* Calculate base salary yearly / 26 */
var salary = 0.0;
if(document.getElementById('categoryIDBox').value == "CAT A - Manufacturing") {
salary = 55000;
} else if(document.getElementById('categoryIDBox').value == "CAT B - Accounting") {
salary = 69500;
} else if(document.getElementById('categoryIDBox').value == "CAT C - Administrative") {
salary = 58700;
} else if(document.getElementById('categoryIDBox').value == "CAT D - IT") {
salary = 73200;
}
  
/* Adjust based on shift */
if(document.getElementById('shiftBox').value == "Night") {
salary = salary + (salary*0.1);
} else if(document.getElementById('shiftBox').value == "Rotating") {
salary = salary + (salary*0.15);
}
  
/* Discount Health Plan */
if(document.getElementById('radioRow').value == "None") {
salary += (salary + (salary*0.02));
} else if(document.getElementById('radioRow').value == "HMO") {
salary += (salary + (salary*0.09));
} else if(document.getElementById('radioRow').value == "PMO") {
salary += (salary + (salary*0.11));
}

// the salary is to be divided by 26 since this is paid fornightly.

return (salary / 26).toFixed(2);
}
function validateFields() {
if(document.getElementById('firstNameBox').length == 0)
return false;
if(document.getElementById('lastNameBox').length == 0)
return false;
if(document.getElementById('addressBox').length == 0)
return false;
if(document.getElementById('cityBox').length == 0)
return false;
if(document.getElementById('stateBox').length == 0)
return false;
if(document.getElementById('zipBox').length == 0)
return false;
return true;
}
/* end of code */
  
</script>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote