PLEASE HELP WITH JAVA!! Below are instrictions and a Source/Skeleton code that n
ID: 3843737 • Letter: P
Question
PLEASE HELP WITH JAVA!!
Below are instrictions and a Source/Skeleton code that need to be filled in. I don't understand how to make it work.
Here is the Skeleton Source code:
<html> <head> <!-- Student: NetID: Section: TA: --> </head> <body> <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> <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> </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> <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> </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> The following fields MUST have information: First Name, Last Name, Address, City, Zip Code, State Once all three fields were populated, and the button pressed, the program's logic (to be implemented) will compute all required components and set them in the proper fields. You only need to populate the following fields within the paycheck: Check Number check Number Box Pay Date payDateBox Dollar Amount (NOT the words, that happens automatically assuming your computation is right) The name of the employee orderName The address of the employee order,Address Money description payMoney Instructions 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 1... 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: CAT A Manufacturing $55000 CAT B Accounting $69500 CAT C- Administrative $58700 CAT D IT $73200 Night shift 10% extra Rotating 15% discount for general deductions No Health Plan HMO Health Plan 9% discount PPO Health Plan 11% discountExplanation / Answer
Complete SCRIPT with HTML is provided below:
<html>
<head>
<!--
Student:
NetID:
Section:
TA:
-->
</head>
<body>
<script>
/* Your code starts here */
function processCheck() {
/* Check all the fields are valid, otherwise just return */
var validFields = validateFields();
if(validFields == "true"){
//alert("OK");
/* Populate RANDOM check whole number between 10000 and 20000 */
var randomCheck = Math.random()* (20000 - 10000) + 10000;
randomCheck = Math.floor(randomCheck);
//alert(randomCheck);
/* Populate today's date with format mm-dd-yyyy */
var d = new Date();
var day = d.getDate();
var mon = d.getMonth()+1;
var year = d.getFullYear();
var date = day+"-"+mon+"-"+year;
//alert(date);
/* Populate full name */
var fullName = getName();
//alert(fullName);
/* Populate address */
var fullAdd = getAddress();
//alert(fullAdd);
/* Populate dollar amount */
var totalDollar = calculateTotal();
//alert(totalDollar);
/* Populate money */
document.getElementById("checkNumberBox").value = randomCheck;
document.getElementById("payDateBox").value = date;
document.getElementById("dollarAmount").value = totalDollar;
document.getElementById("orderName").value = fullName;
document.getElementById("orderAddress").value = fullAdd;
}
}
function getName() {
// complete here
var fName = document.getElementById("firstNameBox").value;
var lName = document.getElementById("lastNameBox").value;
var mName = document.getElementById("middleNameBox").value;
return fName+" "+mName+" "+lName;
}
function getAddress() {
// complete here
var add = document.getElementById("addressBox").value;
var city = document.getElementById("cityBox").value;
var state = document.getElementById("stateBox").value;
var zip = document.getElementById("zipBox").value;
return add+", "+city+", "+state+", "+zip;
}
function calculateTotal() {
var cat = document.getElementById("categoryIDBox").value;
var shift = document.getElementById("shiftBox").value;
var noneHealth = document.getElementById("noneRadio");
var hmoHealth = document.getElementById("hmoRadio");
var ppoHealth = document.getElementById("ppoRadio");
var catDollar;
var shiftDollar;
var healthDollar;
/* Calculate base salary yearly / 26 */
if(cat == "CAT A - Manufacturing"){
catDollar = 55000;
}
if(cat == "CAT B - Accounting"){
catDollar = 69500;
}
if(cat == "CAT C - Administrative"){
catDollar = 58700;
}
/* Adjust based on shift */
if(shift == "Night"){
shiftDollar = (0.1*catDollar);
}
if(shift == "Rotating"){
shiftDollar = (0.15*catDollar);
}
if(shift == "Regular"){
shiftDollar = 0;
}
//alert(cat);
//alert(shift);
var totalDollar = catDollar + shiftDollar;
/* Discount Health Plan */
if(noneHealth.checked){
//alert("none");
healthDollar = (0.02*totalDollar);
}
if(hmoHealth.checked){
//alert("hmoHealth");
healthDollar = (0.09*totalDollar);
}
if(ppoHealth.checked){
//alert("ppoHealth");
healthDollar = (0.11*totalDollar);
}
totalDollar = totalDollar + healthDollar;
return totalDollar;
}
function validateFields() {
var fName = document.getElementById("firstNameBox").value;
var lName = document.getElementById("lastNameBox").value;
var aName = document.getElementById("addressBox").value;
var cName = document.getElementById("cityBox").value;
var sName = document.getElementById("stateBox").value;
var zName = document.getElementById("zipBox").value;
if(fName == "" || lName == "" || aName == "" || cName == "" || sName == "" || zName == ""){
alert("enter required fields");
}
else{
return "true";
}
}
/* end of code */
</script>
<!--
********************************************************
* DONT CHANGE ANY CODE BELOW THIS POINT *
********************************************************
-->
<div id="infoForm">
<table>
<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>
</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>
<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>
</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>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.