Write a JavaScript function to determine the building assignment for employees. Input the department and pay type. Salaried IT employees go to Iona. Hourly IT employees to to Ithaca. Salaried manufacturing employees to to Miner while hourly manufacturing employees go to McCook. Salaried accounting employees go to Armstrong while hourly manufacturing employees go to Aldrin. Display their building assignment
Here is the answer for your requirement in JavaScript Programming language.
NOTE:
1.To give you better understanding of how the function works, I have created an HTML file through which you can give input.
2.While you are giving input, a table will be displayed with Department name,paytype and building assignment.
JavaScript Code :
<script> function building() { //To prompt the user for department and paytypes var department = prompt("Enter Department Name\nAvailable Departments are : \n1.IT\n2.Manufacturing\n3.Accounting"); var paytype = prompt("Enter Pay type\nAvailable Paytypes are : \n1.Salaried\n2.Hourly"); //Getting the table with id "building" from webpage var table = document.getElementById("building"); //If-else statements with particular department with given paytypes will be checked //As per the requrement employee with given department with given paytype //will be assigned to particular person assigned. if(department == "IT" && paytype == "Salaried") { //To create a row in the table var row = table.insertRow(-1); //To insert cells<td>s in each row var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); //To insert data in each cell cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Lona"; } else if(department == "IT" && paytype == "Hourly") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Ithica"; } else if(department == "Manufacturing" && paytype == "Salaried") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Miner"; } else if(department == "Manufacturing" && paytype == "Hourly") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "McCook"; } else if(department == "Accounting" && paytype == "Salaried") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Armstrong"; } else if(department == "Accounting" && paytype == "Hourly") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Aldrin"; }//If input is invalid then an alert message is displayed else { window.alert("Invalid details given..Please check"); } } </script> |
HTML file with internal JavaScript code in it.
Building_Assignment.html
<!DOCTYPE html> <html> <head> <title>Building Assignment</title> <style> table,th,td { cell-spacing: 15px; border : 1px solid green; border-collapse : collapse; } th { background-color:lightgreen; } </style> <script> function building() { //To prompt the user for department and paytypes var department = prompt("Enter Department Name\nAvailable Departments are : \n1.IT\n2.Manufacturing\n3.Accounting"); var paytype = prompt("Enter Pay type\nAvailable Paytypes are : \n1.Salaried\n2.Hourly"); //Getting the table with id "building" from webpage var table = document.getElementById("building"); //If-else statements with particular department with given paytypes will be checked //As per the requrement employee with given department with given paytype //will be assigned to particular person assigned. if(department == "IT" && paytype == "Salaried") { //To create a row in the table var row = table.insertRow(-1); //To insert cells<td>s in each row var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); //To insert data in each cell cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Lona"; } else if(department == "IT" && paytype == "Hourly") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Ithica"; } else if(department == "Manufacturing" && paytype == "Salaried") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Miner"; } else if(department == "Manufacturing" && paytype == "Hourly") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "McCook"; } else if(department == "Accounting" && paytype == "Salaried") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Armstrong"; } else if(department == "Accounting" && paytype == "Hourly") { var row = table.insertRow(-1); var cell1 = row.insertCell(0); var cell2 = row.insertCell(1); var cell3 = row.insertCell(2); cell1.innerHTML = department; cell2.innerHTML = paytype; cell3.innerHTML = "Aldrin"; }//If input is invalid then an alert message is displayed else { window.alert("Invalid details given..Please check"); } } </script> </head> <body> <!--Table with particular id "building"--> <center><table id="building" width="50%"> <tr><th>Department</th><th>Pay Type</th><th>Building Assignment</th></tr> </table> <!--Button that allows you to add an employee to table--> </center><br/><br/><br/> <center><button onclick="building()" style="background-color:green;width:100px;color:white;border-radius:5px;border-color:green;"> Add an Employee</button></center> </body> </html> |
SCREENSHOTS
OUTPUT
After entering some values the table looks like :
NOTE : As complete flow is not mentioned including the design of output took this type of webpage, my sincere apalogy if web page does not meet your idea. But the function is written completely as per the question given. Any doubts can be explained with pleasure :)
Write a JavaScript function to determine the building assignment for employees. Input the department and pay...
Write a Java application with a class name of Payroll, for the “Travel Agency”, that willCalculate the weekly paycheck for both Salaried and Hourly employees. Salaried employees will be paid 1/52 of their annual pay minus 18% withheld for federal and state taxes, as well as 4% for retirement pension. Salaried employees do not collect overtime pay. There are two types of Hourly employees; permanent employees and temporary weekly employees. •Permanent weekly employees will be paid their hourly rate minus...
Lab 1 Q1. Write a Python program with the following function building block. •All input values are to be taken fro m the user. •Ensure to check for possible error cases like mismatch of data type and input out of range, for every function. Function 1: countVowels(sentence) – Function that returns the count of vowels in a sentence. Function 2: Sum of all even numbers between two numbers, identify number of parameters Q2. Write a Python program that reads a...
In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...
Add JavaScript code in the “find_primeV2.js” to allow users to enter a number, and then based on the number of user enters, to find out how many prime numbers there are up to and including the user inputted number and then display them on the web page. The following are the detailed steps to complete this assignment: Step 1. [30 points] In “find_primeV2.js”, complete isPrime() function by (1) Adding one parameter in function header. That parameter is used to accept...
(JAVA Please) Program 1: FICA!? What’s FICA? If you’re taking this course, chances are that you’re going to make a pretty good salary – especially 3 to 5 years after you graduate. When you look at your paycheck, one of the taxes you pay is called FICA – or Federal Insurance Contributions Act. In simplest terms, it’s what funds our Social Security and Medicare systems (and the more that you work, the more you get). Interestingly, your employer will pay...
I am having a hard time with my program to assignment 4.12. Here are the instructions: The Payroll Department keeps a list of employee information for each pay period in a text file. The format of each line of the file is the following: <last name> <hours worked> <hourly wage> Write a program that inputs a filename from the user and prints to the terminal a report of the wages paid to the employees for the given period. The report...
Program 1: Social Security Payout. If you’re taking this course, chances are that you’re going to make a pretty good salary – especially 3 to 5 years after you graduate. When you look at your paycheck, one of the taxes you pay is called Social Security. In simplest terms, it’s a way to pay into a system and receive money back when you retire (and the longer you work and the higher your salary, the higher your monthly benefit). Interestingly,...
read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...
For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....
I need help writting a Javascript function that does the following its for a HTML/CSS Shopping Cart Page CODE This page contains a list of the selected products that includes an image, name, price, quantity, and cost) Because the process is implemented not as real, three products along with its image and price are displayed on the page. The product ID of each product is stored in a hidden textbox. The default amount of each product is 1 and the...