0% found this document useful (0 votes)
27 views2 pages

Javascript Program

The document contains code snippets for several JavaScript programs: 1) A program to calculate the total and average of 5 test marks. 2) A program that swaps the values of two variables. 3) A program to calculate HRA, DA, and total salary based on basic salary. 4) Programs to determine if a number is even or odd, greater of two numbers, and if a person is major or minor based on their age. 5) A program to calculate HRA and DA at different rates depending on if basic salary is above or below 15,000. 6) A program to determine the greatest of three numbers. 7) A program to determine division (1st
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views2 pages

Javascript Program

The document contains code snippets for several JavaScript programs: 1) A program to calculate the total and average of 5 test marks. 2) A program that swaps the values of two variables. 3) A program to calculate HRA, DA, and total salary based on basic salary. 4) Programs to determine if a number is even or odd, greater of two numbers, and if a person is major or minor based on their age. 5) A program to calculate HRA and DA at different rates depending on if basic salary is above or below 15,000. 6) A program to determine the greatest of three numbers. 7) A program to determine division (1st
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

//Program to find average and total marks

var m1=45,m2=55,m3=65,m4=75,m5=85,total,avg;
total=m1+m2+m3+m4+m5;
avg=total/5;
document.write("total="+total+"<br/>");
document.write("Average="+avg+"<br/>");

//Swapping
var a=10,b=20,t;
document.write("a= "+a+"b= "+b+" before swapping <br/>");
t=a;
a=b;
b=t;
document.write("a= "+a+"b= "+b+" after swapping <br/>");

//Program to find hra,da and ts


var bs=2355,hra,da,ts;
hra=.40*bs;
da=.35*bs;
ts=bs+hra+da;
document.write("hra="+hra+"<br/>");
document.write("da="+da+"<br/>");
document.write("ts="+ts+"<br/>");

//Program to find age major or minor


var a=15;
if(a>=18)
document.write("Major");
else
document.write("Minor");

//Program to find greatest of two numbers


var a=15,b=24;
if(a>b)
document.write("A is greatest");
else
document.write("B is greatest");

//Program to find even or odd


var a=15;
if(a%2==0)
document.write("Even");
else
document.write("Odd");

//Program to check if basic salary is greater then 15000

var bs=20000,hra,da,ts;
if(bs>15000)
{
hra=.40*bs;
da=.35*bs;
}
else
{
hra=.35*bs;
da=.30*bs;
}
ts=hra+da+bs;
document.write("hra="+hra+"<br/>");
document.write("da="+da+"<br/>");
document.write("ts="+ts+"<br/>");

//Greatest of three numbers

var a=10,b=20,c=30;
if(a>b)
if(a>c)
document.write("A is greatest");
else
document.write("C is greatest");
else
if(b>c)
document.write("B is greatest")
else
document.write("C is greatest");

//Program to find division based on percentage

var p=45;
if(p>=60)
document.write("First Division");
else
if(p>=50)
document.write("2nd Division");
else
if(p>=40)
document.write("3rd Division");
else
document.write("Fail");

You might also like