Calculating employee's marks in a training program
Hi all,
If someone has some chance, could i be assisted with the below program please?
The program should get marks achieved from mgt1, mgt2, mgt3, mgt4, mgt5, mgt6 and comp15 training courses from employees.
It would then find the highest marks from the 6 marks entered by the employee.
Then it will calculate the decimal equivalent of the each piece of assessment and proceed to calculate the weighted mark, find the highest weighted mark and then calculate the weighted mean.
I have written something but got stuck as it is not working.
Can someone please kindly point me in the right direction as i am already crying blood (not tears from my poor eyes)?
/* A program that calculates the Mgt and Comp scores of employees. */ var weightedMean = 0; //stores the weighted mean after it has been calculated var weightedMarksArray = 0; //stores the weighted marks after they have been calculated var assessmentsMarksArray new Array(7); //stores the raw marks for each mgt and the comp15 achieved by the employee var highestWeightedMarksIndex = 0; //stores the weighted highest mark after comparison and calculations var assessmentArray = ("mgtMarks","comp15Mark");; // to store each piece of assessment
var weightingFactorsArray = (mgt1 = 15,mgt2 =20,mgt3 =20,mgt4 = 20,mgt5 = 20,mgt6 = 20, comp15 = 5); // weighting factors var highestMarkIndex = 0; //stores the highest marks after comparison var weightsArray; // stores the contribution of each piece of assessment as a decimal equivalent of the percentage contribution(not the actual contribution)
/* loop to read in and add the 7 assessment marks to assessment marks array */
for (var count = 0; count < 6; ++count)
{
assessmentMarksArray[count] = parseFloat(window.prompt('Please enter the marks achieved for mgt module ' + (count + 1),''));
}
assessmentMarksArray = parseFloat(window.prompt('Please enter the mark achieved for comp15',''));
/* determines assessment with highest marks */
highestMarkIndex = assessmentMarksArray[0]; for (var assessment = 1; assessment < assessmentMarksArray.length; ++assessment)
{ if (assessmentMarksArray[assessment] > assessmentMarksArray[highestMarkIndex])
{
highestMarkIndex = assessment;
}
}
/* calculates the decimal equivalent of each piece of assessment*/ for (var assessment = 0; assessment < assessmentMarksArray.length; ++assessment)
{
weightsArray[assessment] = weightingFactorsArray[assessment] / 100;
}
/* calculates the weighted mark for each piece of assessment */ for (var assessment = 0; assessment < assessmentMarksArray.length; ++assessment)
{
weightedMarksArray[assessment] = assessmentMarksArray[assessment] * weightsArray[assessment];
}
/* determines the piece of assessment with the highest weighted marks */
highestWeightedMarksIndex = assessmentMarksArray[0]; for (var assessment = 1; assessment < weightedMarksArray.length; ++assessment)
{ if (weightedMarksArray[assessment] > weightedMarksArray[highestWeightedMarksIndex])
{
highestWeightedMarksIndex = assessment;
}
}
/* calculates weighted mean of assessments by summing all the individual weighted marks*/
weightedMean = 0;
document.write('The weighted mean is: ', weightedMean, '<BR>');
document.write(highestScoreIndex[assessment] 'has the highest raw score of ', highestScoreIndex, '<BR>');
document.write(highestWeightedScoresIndex[assessment] 'has the highest weighted score of ', highestWeightedScoresIndex, '<BR>');
</script>
</body>
</html>
Hundreds of times every week we see people post a huge ugly script
right into the message, this code in most cases is too hard to read.
Pease use the built in vB code formatting using<br/>
square bracket PHP square bracket<br/>
This will color code your script good enough for readability.<br/> If you use that your code may look like this
If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
The same applies to HTML and the forums [HTML][/HTML] tags.
Calculating employee's marks in a training program
Hi all,
If someone has some chance, could i be assisted with the below program please?
The program should get marks achieved from mgt1, mgt2, mgt3, mgt4, mgt5, mgt6 and comp15 training courses from employees.
It would then find the highest marks from the 6 marks entered by the employee.
Then it will calculate the decimal equivalent of the each piece of assessment and proceed to calculate the weighted mark, find the highest weighted mark and then calculate the weighted mean.
I have written something but got stuck as it is not working.
Can someone please kindly point me in the right direction as i am already crying blood (not tears from my poor eyes)?
Any form of help will be appreciated.
Thanks
See code below:
HTML Code:
<head><title>Employees_marks</title></head><body><script type="text/javascript">
/* A program that calculates the Mgt and Comp scores of employees. */
var weightedMean = 0; //stores the weighted mean after it has been calculated
var weightedMarksArray = 0; //stores the weighted marks after they have been calculated
var assessmentsMarksArray new Array(6); //stores the raw marks for each mgt and the comp15 achieved by the employee
var highestWeightedMarksIndex = 0; //stores the weighted highest mark after comparison and calculations
var assessmentArray = ("mgtMarks","comp15Mark");; // to store each piece of assessment
var weightingFactorsArray = (mgt1 = 15,mgt2 =20,mgt3 =20,mgt4 = 20,mgt5 = 20, comp15 = 5); // weighting factors
var highestMarkIndex = 0; //stores the highest marks after comparison
var weightsArray; // stores the contribution of each piece of assessment as a decimal equivalent of the percentage contribution(not the actual contribution)
/* loop to read in and add the 7 assessment marks to assessment marks array */
for (var count = 0; count < 6; ++count)
{
assessmentMarksArray[count] = parseFloat(window.prompt('Please enter the marks achieved for mgt module ' + (count + 1),''));
}
assessmentMarksArray = parseFloat(window.prompt('Please enter the mark achieved for comp15',''));
/* determines assessment with highest marks */
highestMarkIndex = assessmentMarksArray[0];
for (var assessment = 1; assessment < assessmentMarksArray.length; ++assessment)
{
if (assessmentMarksArray[assessment] > assessmentMarksArray[highestMarkIndex])
{
highestMarkIndex = assessment;
}
}
/* calculates the decimal equivalent of each piece of assessment*/
for (var assessment = 0; assessment < assessmentMarksArray.length; ++assessment)
{
weightsArray[assessment] = weightingFactorsArray[assessment] / 100;
}
/* calculates the weighted mark for each piece of assessment */
for (var assessment = 0; assessment < assessmentMarksArray.length; ++assessment)
{
weightedMarksArray[assessment] = assessmentMarksArray[assessment] * weightsArray[assessment];
}
/* determines the piece of assessment with the highest weighted marks */
highestWeightedMarksIndex = assessmentMarksArray[0];
for (var assessment = 1; assessment < weightedMarksArray.length; ++assessment)
{
if (weightedMarksArray[assessment] > weightedMarksArray[highestWeightedMarksIndex])
{
highestWeightedMarksIndex = assessment;
}
}
/* calculates weighted mean of assessments by summing all the individual weighted marks*/
weightedMean = 0;
for (var assessment = 0; assessment < weightedMarksArray.length; ++assessment)
{
weightedMean = sumElements(weightedMarksArray)
}
document.write('The weighted mean is: ', weightedMean, '<BR>');
document.write(highestScoreIndex[assessment] 'has the highest raw score of ', highestScoreIndex, '<BR>');
document.write(highestWeightedScoresIndex[assessment] 'has the highest weighted score of ', highestWeightedScoresIndex, '<BR>');
</script></body>
(1): If i wanted the employee to enter the marks individually so that each prompt window to enter the marks comes up separately, how should i do it?
Why do you want prompt windows, they are bad for the most part, make a mistake and you can't fix it, not all browsers let you take focus off the window, and they cannot be skinned to your pages appearance.
(2): Again how do i round the outputted weighted mean to 1 decimal place?
Thanks
Code:
ele.appendChild(document.createTextNode('The Weighted mean is ' + (total / i).toFixed(1)));
If you are using PHP please use the [PHP] and [/PHP] forum tags for highlighting...
The same applies to HTML and the forums [HTML][/HTML] tags.
Bookmarks