JAVASCRIPT
Hello, I would like some help
there are the directions:
You have 5 employees. Write a program that asks for the employee name and their total sales for the month. Calculate their commission which is10% of the total sales. They will receive a bonus based on their total sales.
|
Sales |
Bonus |
|
0 - 1000 |
0 |
|
1001 - 10000 |
100 |
|
Over 10000 |
1000 |
Display each of the employee’s commission and bonus. After all 5 employees have been entered, display the total sales, total commission, and total bonus for all employees.
Here is my code so far:
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<table border="1">
<thead>
<tr>
<td>Name</td>
<td>Sales</td>
<td>Commission</td>
<td>Bonus</td>
</tr>
</thead>
<tbody id="table">
</tbody>
<tfoot>
<tr>
<td colspan="3">Total Sales :</td>
<td id="tSales"></td>
</tr>
<tr>
<td colspan="3">Total Commission :</td>
<td id="tCom"></td>
</tr>
<tr>
<td colspan="3">Total Bonuses :</td>
<td id="tBonus"></td>
</tr>
</tfoot>
</table>
<script>
var question = 0;
var nameList =[];
salesList = [];
totalList = [];
while (question < 5) {
var name = prompt("Enter Employee Name");
var sales = Number(prompt("Enter Number of Sales"));
nameList.push(name);
salesList.push(sales);
question++;
}
var table = document.getElementById("table");
var htmlStr = "";
for (let i = 0; i < 3; i++) {
htmlStr += "<tr>";
htmlStr += `<td>${nameList[i]}</td>`;
htmlStr += `<td>${saleList[i]}</td>`;
htmlStr += `<td>${totalList[i]}</td>`;
htmlStr += "</tr>";
}
var total = salesList.reduce((a, b) => a + b, 0);
var bonus = 0;
if (total <= 1000)
bonus = 0;
else if (total > 1000 && total >= 10000)
bonus = 100;
else if(total > 10001)
bonus = 1000;
var table = document.getElementById("table");
var htmlStr = "";
for (let i = 0; i < 3; i++) {
htmlStr += "<tr>";
htmlStr += `<td>${nameList[i]}</td>`;
htmlStr += `<td>${saleList[i]}</td>`;
htmlStr += `<td>${quanList[i]}</td>`;
htmlStr +=
`<td>${(costList[i]).toFixed(2)}</td>`;
htmlStr += "</tr>";
}
</script>
</body>
</html>
thank you
Answer:
Here is code:
<!DOCTYPE html>
<html>
<head>
</head>
<style>
tr:hover {
background-color: #f5f5f5;
}
table {
text-align: center;
}
</style>
<body>
<table border="1">
<thead>
<tr>
<td>Name</td>
<td>Sales</td>
<td>Commission</td>
<td>Bonus</td>
</tr>
</thead>
<tbody id="table">
</tbody>
</table>
<script>
var size = 5
var employee = [];
for (let i = 0; i < size; i++) {
var name = prompt("Enter Employee Name");
var sales = Number(prompt("Enter Number of Sales"));
var commission = sales * .10;
var bonus = 0;
if (sales <= 1000) {
bonus = 0
} else if (sales <= 10000) {
bonus = 100;
} else {
bonus = 1000;
}
var data = {
name: name,
sales: sales,
commission: commission,
bonus: bonus
}
employee.push(data);
}
var table = document.getElementById("table");
var htmlStr = "";
for (let i = 0; i < employee.length; i++) {
htmlStr += "<tr>";
htmlStr += `<td>${employee[i].name}</td>`;
htmlStr += `<td>${employee[i].sales}</td>`;
htmlStr += `<td>${employee[i].commission}</td>`;
htmlStr += `<td>${employee[i].bonus}</td>`;
htmlStr += "</tr>";
}
table.innerHTML = htmlStr;
</script>
</body>
</html>
Output:

JAVASCRIPT Hello, I would like some help there are the directions: You have 5 employees. Write...
How to make all the buttons work using javascript? <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script> function openAccount() { /* - get the account and initial amount values - check that all necessary information is provided - call the setCookie function to create account */ } function Deposit() { /* - get the account and amount values - check that all necessary information is provided - alter cookie with current amount of deposit */ } function...
Read the following problem: You order some groceries online and buy 5 things: Yellow Corn Tortillas $3.32 Cheddar Cheese $5.89 Avocados $4.41 Cilantro $0.99 Jalapeno pepper $0.39 The website calculates the price and it is displayed as the "Subtotal". The website charges 11% sales tax and it is displayed as the "Sales tax". The overall price is calculated and it is displayed as the "Total price". Based on the following HTML: <table> <caption>Details</caption> <thead> <tr><th>Item</th><th>Price</th></tr> </thead> <tbody> <tr><td>Yellow Corn Tortillas</td><td...
I need to complete 3 validation cases in this Javascript code. I need to validate email, phone and street address. How would I go about validating these 3 cases in this code: <!DOCTYPE html> <html> <head> <meta charset="UTF-8" /> <title>Week 10: Regular Expressions</title> <style type="text/css"> span { padding: 2px; } .success { color: #008000; background: #99cc99; } .failure { color: #ff0000; background: #ff9999; } </style> <script type="text/javascript"> function validateInput(form) { var result0 = document.getElementById('result0'), result1 = document.getElementById('result1'), result2 = document.getElementById('result2'),...
JAVASCRIPT/JQUERY Hello I would like some help understanding jQuery. Here are the directions: Write a program that creates the following table: Course Course Name Day Time IMS115 Windows 10 Monday 6 PM IMS215 Office 2016 Wednesday 5 PM MIS200 Java Thursday 9 AM MTH105 Business Math Saturday 10 AM Using jQuery, select every other odd row and change the font color to blue and make it bold. And here is my code: Chapter4.html <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="Chapter4.css">...
I have to make a pixel art maker using javascript. HTML and CSS were already provided. I only had to do the JavaScript part. Every time I run the HTML folder nothing happens when I choose the width, height, and color. This is my code: (ONLY JS IS SUPPOSED TO BE FIXED). JS: // Select color input // Select size input const colorPicker = document.getElementsById('colorPicker'); const rowNum = document.getElementsById('inputHeight'); const cellNum = document.getElementById('inputWidth'); const pixelCanvas = document.getElementById('pixelCanvas'); const form =...
I have some code for HTML/Javascript but I need to change it up a bit. Heres the assignment and what I have. The part in the bold is what I need help with. I need a button called new timer for when it reaches zero... Thank you. Assignment For this assignment, you will write a timer application in HTML and JavaScript. Your HTML document should contain the following elements/features: HTML tags: An <input> tag labeled "Timer Duration" with the initial...
Hello, this is my code. moest of the things works but when select the price, i just dont get my total. can someone help me out . thank you My queshion is also here The page will simulate the site for a Chicago-based small bus line that travels to St Louis, Milwaukee, and Detroit. Here are the requirements: The home page (i.e. the main page) should simply be the heading, image, and slogan of the site. The home page should NOT...
I need help incorporating javascript into my page. The Lessons page has a message box (not an alert box) that becomes visible/invisible when the mouse is moved over/off the small, red hyperlink on the last line that says, "note." The note is 10pt, red, and italic. The message box contains the text, "Students who pre-pay for the entire term will have the registration fee waved." It is 150px wide, with an "azure" background and a black border. It has 5px...
I am trying to create a slide show using JavaScript. This is what I have so far: HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Slide Show</title> <link rel="stylesheet" href="main.css"> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="slide_show.js"></script> </head> <body> <section> <h1>Fishing Slide Show</h1> <ul id="image_list"> <li><a href="images/casting1.jpg" title="Casting on the Upper Kings"></a></li> <li><a href="images/casting2.jpg" title="Casting on the Lower Kings"></a></li> <li><a href="images/catchrelease.jpg" title="Catch and Release on the Big Horn"></a></li> <li><a href="images/fish.jpg" title="Catching on the South Fork"></a></li> <li><a href="images/lures.jpg" title="The Lures for Catching"></a></li> </ul>...