Computer Science,Computer Security, GSM Cell Phones and Latest Technolgy Blog
This is the site for computer science related technology, programming languages, JAVA, ASP.net, Java Beans and servelet, Oracle procedures and triggers, SQL, Computer Security, Networking, Hacking related articles.

 

Google has extended far beyond its core search business to provide a variety of new services, including free email, Web hosting, and business applications. It only makes sense to pay attention to what Google has to offer and take advantage of the services that can help you. Google is constantly expanding its services and acquiring new technologies.There is also the important matter of your time and energy. The truth is that if you look through all of the services and utilities made available by Google (a list that seems to grow all the time), you’ll find many more than 20 tools. Learning to make the most of what these services have to offer can make a difference to anyone wanting to get a new online business off the ground or improve the reach and success level of an existing small- to medium-size company. Here is a list of 20 of the tools you’re likely to find most useful:

1. Google’s search service. Google indexes and organizes the contents of the Web in a huge database; it’s this database that you use to search the Web.

2. AdWords. This is a paid search placement program; you create ads and bid on how much you’ll pay for each click the ad attracts. Each time someone
clicks on your ad, you gain a potential customer or client.

3. AdSense. This program enables blog and Web site owners to run targeted ads alongside their content; the content of the ads is intended to complement what you’ve published yourself .

4. Google Apps. This service provides you with a domain name (for a one-time $10 fee) and enables you to use a suite of business applications, which multiple users can access.

5. Google Docs & Spreadsheets. This exciting and easy-to-use service gives you a word processor and a spreadsheet application that you can use and access for free.

6. Google Calendar. A default calendar is created for you when you sign up for Google Apps; you can also create custom calendars and even embed calendars in Web pages.

7. Gmail. Google’s e-mail application comes with lots of storage space and an integrated chat client to boot.

8. Google Talk. Google’s chat application lets you send instant messages and even conduct real-time voice conversations through your computer.

9. Google Page Creator. This Web page editing tool lets you create your own Web site to go along with your Google Apps domain name.

10. Blogger. Google’s popular, and free, blogging services lets you create your own Web-based diary, complete with an index, an archive, and a comments feature.

11. Checkout, Google Product Search, Catalogs. These three Google services help commercial businesses sell products online.

12. Google Base. A growing number of entrepreneurs are posting merchandise, property, services, jobs, and lots of other things for sale in this Web publishing area.

13. Google Gadgets. These easy-to-implement bits of Web content can make your Web site more valuable and attract more repeat visits.

14. Analytics, Trends. These two analytical tools provide you with information about visits to your own Web site and trends in Web searches, respectively.

15. Desktop, Toolbar. These two tools help you search more effectively, both through files on your own computer and your local network (Desktop) as well as the wider Internet (Toolbar).

16. Picasa. This powerful photo viewing and editing tool automatically organizes all the files on your desktop and lets you edit them as well.

17. News, Book Search. These tools provide businesspeople with important up-to the-minute data they need to keep on top of trends and events.

18. Google Apps Premium. This corporate version of Google Apps guarantees nearly 24/7 reliability and gives businesses the ability to write custom programs that interface with Google’s services.

19. Gmail Mobile and SMS. These tools let busy professionals search Google and exchange messages when they’re on the road.

20. Google Pack. This suite of applications will boost the functionality of virtually any workstation.

 

Javascript Puzzle

Posted In: . By Wasim

(15 Puzzle) Write a web page that enables the user to play the game of 15. There is a 4-by-4 board (implemented as an XHTML table) for a total of 16 slots. One of the slots is empty. The other slots are occupied by 15 tiles, randomly numbered from 1 through 15. Any tile next to the currently empty slot can be moved into the currently empty slot by clicking on the tile. Your program should create the board with the tiles out of order. The user's goal is to arrange the tiles in sequential order row by row. Using the DOM and the onclick event, write a script that allows the user to swap the positions of the open position and an adjacent tile. [Hint: The onclick event should be specified for each table cell.]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>puzzle</title>
<script type="text/javascript">
<!--
function puzzle()
{
for(var i = 0; i < 500; i++)
{
var moves = new Array(); // The set of valid moves
var pos = 0; // The number of candidate valid moves
/* Find blank */
for(var blankpos = 0; blankpos< 16; blankpos++)
{
if(slot(blankpos).innerText == "0")
{
/* Find moves */
if((blankpos % 4) > 0)
{
moves[pos++] = blankpos - 1; // Left
}
if((blankpos % 4) < 3)
{
moves[pos++] = blankpos + 1; // Right
}
if(blankpos > 3)
{
moves[pos++] = blankpos - 4; // Up
}
if(blankpos < 12)
{
moves[pos++] = blankpos + 4; // Down
}
}
}
/* Move random candidate */
moveSlot(moves[(Math.floor(Math.random() * moves.length))]);
}
}
function moveSlot(pos)
{
var move = -1; // The cell to which to move
if((pos % 4) > 0 && slot(pos - 1).innerText == "0")
{
move = pos - 1; // Left
}
if((pos % 4) < 3 && slot(pos + 1).innerText == "0")
{
move = pos + 1; // Right
}
if(pos > 3 && slot(pos - 4).innerText == "0")
{
move = pos - 4; // Up
}
if(pos < 12 && slot(pos + 4).innerText == "0")
{
move = pos + 4; // Down
}
if(move > -1)
{
slot(move).innerText = slot(pos).innerText;
slot(move).className = slot(pos).className;
slot(pos).innerText = "0";
slot(pos).className = "blankpos";
}
}
// -->
</script>
<style type="text/css">
b
{
font-size:100;
display:inline;
height:60;
width:60;
}
.blankpos
{
display:none;
}
</style>
<style type="text/css">
p.c2
{
text-align:center;
}
button.c1
{
font-size:20;
width:160;
}
.style1 {
color: #000066;
font-weight: bold;
}
</style>
</head>
<body>
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1>Puzzle</h1>
<hr />

<p>(15 Puzzle) Write a web page that enables the user to play the game of 15. There is a 4-by-4 board (implemented as an XHTML table) for a total of 16 slots. One of the slots is empty. The other slots are occupied by 15 tiles, randomly numbered from 1 through 15. Any tile next to the currently empty slot can be moved into the currently empty slot by clicking on the tile. Your program should create the board with the tiles out of order. The user's goal is to arrange the tiles in sequential order row by row. Using the DOM and the onclick event, write a script that allows the user to swap the positions of the open position and an adjacent tile. [Hint: The onclick event should be specified for each table cell.</p>
<table border="1" align="center" bgcolor="pink">
<center>
<tr>
<td><button id="slot" class="b" onclick="moveSlot(0)">01 </button></td>
<td><button id="slot" class="b" onclick="moveSlot(1)">02</button></td>
<td><button id="slot" class="b" onclick="moveSlot(2)">03</button></td>
<td><button id="slot" class="b" onclick="moveSlot(3)">04</button></td>
</tr>
</center>
<center>
<tr>
<td><button id="slot" class="b" onclick="moveSlot(4)">05</button></td>
<td><button id="slot" class="b" onclick="moveSlot(5)">06</button></td>
<td><button id="slot" class="b" onclick="moveSlot(6)">07</button></td>
<td><button id="slot" class="b" onclick="moveSlot(7)">08</button></td>
</tr>
</center>
<center>
<tr>
<td><button id="slot" class="b" onclick="moveSlot(8)">09</button></td>
<td><button id="slot" class="b" onclick="moveSlot(9)">10</button></td>
<td><button id="slot" class="b" onclick="moveSlot(10)">11</button></td>
<td><button id="slot" class="b" onclick="moveSlot(11)">12</button></td>
</tr>
</center>
<center>
<tr>
<td><button id="slot" class="b" onclick="moveSlot(12)">13</button></td>
<td><button id="slot" class="b" onclick="moveSlot(13)">14</button></td>
<td><button id="slot" class="b" onclick="moveSlot(14)">15</button></td>
<td><button id="slot" class="blankpos" onclick="moveSlot(15)">0</button></td>
</tr>
</center>
</table>
<p class="c2"><button onclick="puzzle()" class="c1">New Game</button></p>
</td>
</tr>
</table>

</body>
</html>

 

Write a script that uses random number generation to create sentences. Use four arrays of strings called article, noun, verb and preposition. Create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article and noun. As each word is picked, concatenate it to the previous words in the sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period.
The arrays should be filled as follows: the article array should contain the articles "the", "a", "one", "some" and "any"; the noun array should contain the nouns "boy", "girl", "dog", "town" and "car"; the verb array should contain the verbs "drove", "jumped", "ran", "walked" and "skipped"; the preposition array should contain the prepositions "to", "from", "over", "under" and "on".
The program should generate 20 sentences to form a short story and output the result to an XHTML textarea. The story should begin with a line reading "Once upon a time..." and end with a line reading "THE END".

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Sentences</title>
<script type="text/javascript">
<!--
function sentence()
{
var i;
var article= new Array(5);
article[0]="the";
article[1]="a";
article[2]="one";
article[3]="some";
article[4]="any";
var noun= new Array(5);
noun[0]="boy";
noun[1]="girl";
noun[2]="dog";
noun[3]="town";
noun[4]="car";
var verb= new Array(5);
verb[0]="drove";
verb[1]="jumped";
verb[2]="ran";
verb[3]="walked";
verb[4]="skipped";
var preposition= new Array(5);
preposition[0]="to";
preposition[1]="from";
preposition[2]="over";
preposition[3]="under";
preposition[4]="on";
var string1="Once upon a time..." ;
for(i = 0; i < 20; i++)
{
string1 = string1 + caps(article[Math.floor(Math.random()*5)]) + " " + noun[Math.floor(Math.random()*5)] + " " + verb[Math.floor(Math.random()*5)] + " " + preposition[Math.floor(Math.random()*5)] + " " + article[Math.floor(Math.random()*5)] + " " + noun[Math.floor(Math.random()*5)] + "." + "\n";
}
var string2="THE END";
document.writeln(string1 + string2);
}
function caps(a)
{
var first= a.substring(0,1);
var last= a.substring(1);
var output= first.toUpperCase() + last;
return output;
}
// -->
</script>
</head>
<body onload="sentence()">
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1>Exercise 11.7 Sentences</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to Output sentences.</p>
</td>
</tr>
</table>

</body>
</html>

 

Write a script that inputs a line of text, tokenizes it with String method split and outputs the tokens in reverse order.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> ReverseThem </title>

<script type="text/javascript">
<!--
function splitButtonPressed()
{
var inputString = document.getElementById( "string1" ).value;
var tokens = inputString.split( " " );
var len=tokens.length;
var reverse="";
for(i=len-1; i>=0; i--)
{
reverse= reverse +" " + tokens[i];
}
document.getElementById( "ans" ).value = reverse;
} // end function splitButtonPressed
// -->
</script>
</head>
<body>
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1> Reverse Them</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to Reverse Input strings using Split.</p>
<form name = "ReverseThem" action = "">
<table border = "1">
<caption>Compare</caption>
<tr><td>Enter any String to Reverse</td>
<td><input name = "string1" type = "text" />
</td></tr>
<tr><td>Output String</td>
<td><textarea name="ans">
</textarea>
</td></tr>
<tr><td><input type = "button" value = "ReverseThem"
onclick = "splitButtonPressed()" /></td></tr>
</table>
</form>
</td>
</tr>
</table>

</body>
</html>

 

Write a script based on the program that inputs several lines of text and uses String method indexOf to determine the total number of occurrences of each letter of the alphabet in the text. Uppercase and lowercase letters should be counted together. Store the totals for each letter in an array, and print the values in tabular format in an XHTML textarea after the totals have been determined.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CountThem</title>
<script type="text/javascript">
<!--
function search1()
{
var str1 = document.getElementById("string1").value;
var str2 = new Array ("a", "b", "c" , "d", "e", "f", "g" , "h" , "i", "j", "k" , "l" , "m", "n" , "o" , "p" , "q", "r", "s", "t" , "u", "v", "w" , "x", "y" , "z");
var str11=str1.toLowerCase();
var len=str11.length;
document.getElementById("ans").value="" ;
for(i=0;i<26;i++)
{
var count=0;
var search=str11.indexOf(str2[i]);
for(j=0;j<len;j++)
{
if(parseInt(search)!= -1)
{
count++;
var search=str11.indexOf(str2[i],parseInt(search)+1);
}
}
if(count!=0)
{
document.getElementById("ans").value= document.getElementById("ans").value + "\n" + str2[i] + " Occurs " + count + " times";
}
}
}
// -->
</script>
</head>
<body>
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1>CountThem</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to determine the total number of occurrences of each letter of the alphabet in the text .</p>
<form name = "search" action = "">
<table border = "1">
<caption>Search</caption>
<tr><td>Enter any String</td>
<td><input name = "string1" type = "text" />
</td></tr>
<tr><td>Search Result</td>
<td><textarea name="ans" rows="26" cols="20">
</textarea>
</td></tr>
<tr><td><input type = "button" value = "CountThem"
onclick = "search1()" /></td></tr>
</table>
</form>
</td>
</tr>
</table>

</body>
</html>

 

Write a script that inputs several lines of text and a search character and uses String method indexOf to determine the number of occurrences of the character in the text.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>CountIt</title>
<script type="text/javascript">
<!--
function search1()
{
var str1 = document.getElementById("string1").value;
var str2 = document.getElementById("string2").value;
var len=str1.length;
var count=0;
var search=str1.indexOf(str2);
for(i=0;i<len;i++)
{
if(parseInt(search)!= -1)
{
count++;
var search=str1.indexOf(str2,parseInt(search)+1);
}
}
document.getElementById("ans").value= str2 + " Occurs " + count + " times";
}
// -->
</script>
</head>
<body>
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">&nbsp;</td>
<h1>Exercise 11.13 CountIt</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to determine the number of occurrences of the character in the text .</p>
<form name = "search" action = "">
<table border = "1">
<caption>Search</caption>
<tr><td>Enter any String</td>
<td><input name = "string1" type = "text" />
</td></tr>
<tr><td>Enter search Character</td>
<td><input name = "string2" type = "text" />
</td></tr>
<tr><td>Search Result</td>
<td><textarea name="ans">
</textarea>
</td></tr>
<tr><td><input type = "button" value = "SearchIt"
onclick = "search1()" /></td></tr>
</table>
</form>
</tr>
</table>

</body>
</html>

 

Write a script that uses relational and equality operators to compare two Strings input by the user through an XHTML form. Output in an XHTML textarea whether the first string is less than, equal to or greater than the second.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Compare</title>
<script type="text/javascript">
<!--
function compare1()
{
var str1 = document.getElementById("string1").value;
var str2 = document.getElementById("string2").value;
if(str1 != str2)
{
if(str1 > str2)
{
document.getElementById("ans").value= str1 + " Greater than " + str2;
}
else
{
document.getElementById("ans").value= str1 + " Less than " + str2;
}
}
else
{
document.getElementById("ans").value= str1 + " Equals " + str2;
}
}
// -->
</script>
</head>
<body>

<h1> Compare</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to Compare two input strings.</p>
<form name = "compare" action = "">
<table border = "1">
<caption>Compare</caption>
<tr><td>Enter any String</td>
<td><input name = "string1" type = "text" />
</td></tr>
<tr><td>Enter Second String</td>
<td><input name = "string2" type = "text" />
</td></tr>
<tr><td>Output Comparison</td>
<td><textarea name="ans">
</textarea>
</td></tr>
<tr><td><input type = "button" value = "Compare"
onclick = "compare1()" /></td></tr>
</table>
</form>
</body>
</html>

 

Write a script to simulate the rolling of two dice. The script should use Math.random to roll the first die and again to roll the second die. The sum of the two values should then be calculated. [Note: Since each die can show an integer value from 1 to 6, the sum of the values will vary from 2 to 12, with 7 being the most frequent sum, and 2 and 12 the least frequent sums. Figure shows the 36 possible combinations of the two dice. Your program should roll the dice 36,000 times. Use a one-dimensional array to tally the numbers of times each possible sum appears. Display the results in an XHTML table. Also determine whether the totals are reasonable (e.g., there are six ways to roll a 7, so approximately 1/6 of all the rolls should be 7).]


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>ThrowDice</title>
<script type ="text/javascript">
var dice1;
var dice2;
var ans;
var num;
var Number;
var i;
function roll_dice()
{
var random_dice1=Math.floor(Math.random()*6);
return random_dice1+1;
}
function rolling()
{
var combination=new Array();
ans="";
var display;
display="";
num=window.prompt("Enter how many times you want to throw the dice");
for(i=0;i<12;i++)
{
combination[i]=0;
}
for(i=0;i<parseInt(num);i++)
{
dice1=roll_dice();
dice2=roll_dice();
ans=parseInt(dice1)+ parseInt(dice2);
combination[ans-2]+=1;
Number=i+1;
display += "Roll #"+ Number + ": " + dice1 + " " + dice2 + "<br>";
}
div1.innerHTML=display;
var ans1="";
for(i=0;i<11;i++)
{
Number=i+2;
ans1+="The Sum of "+ Number +" occurred :" + combination[i] +" Times<br>"
}
div2.innerHTML=ans1;
}
</script>
</head>
<body onload="rolling()">
<h1> ThrowDice1</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program for Rolling a Dice number of times as prompt by user</p>
<form name = "multiply" action = "">
<table>
<caption>Throw Dice Program1</caption>
<div id="div1">
</div>
<div id="div2"></div>
</table>
</form>
</body>
</html>

 

Javascript Sales People

Posted In: . By Wasim

Use a one-dimensional array to solve the following problem: A company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9 percent of their gross sales for that week. For example, a salesperson who grosses $5000 in sales in a week receives $200 plus 9 percent of $5000, or a total of $650. Write a script (using an array of counters) that obtains the gross sales for each employee through an XHTML form and determines how many of the salespeople earned salaries in each of the following ranges (assume that each salesperson's salary is truncated to an integer amount):
A. $200–299
B. $300–399
C. $400–499
D. $500–599
E. $600–699
F. $700–799
G. $800–899
H. $900–999
I. $1000 and over

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>SalesPay</title>
<script type="text/javascript">
<!--
function calculate()
{
var i=0; var j;
var s = prompt("Enter Gross Sales of an Employee (Exit: -1):", "");
var gross = parseInt(s);
var sal_btwn = [0,0,0,0,0,0,0,0,0,0,0];
while (gross != -1)
{
var income = new Array();
var salary = 200.0 + Math.round(0.09*gross);
income[i]=salary;
document.writeln("The Gross sales made by salesperson in a week is $ ", +gross);
document.write("<br />");
document.writeln("Salesperson's Commission is $", +income[i]);
document.write("<br />");
if (income[i] >= 200 && income[i] <= 299)
{
//alert(income[i]);
//alert(sal_btwn[0]);
sal_btwn[2] += 1;
}
if (income[i]>= 300 && income[i]<= 399)
sal_btwn[3] += 1;
if (income[i]>= 400 && income[i] <= 499)
sal_btwn[4] += 1;
if (income[i] >= 500 && income[i] <= 599)
sal_btwn[5] += 1;
if (income[i] >= 600 && income[i] <= 699)
sal_btwn[6] += 1;
if (income[i] >= 700 && income[i] <= 799)
sal_btwn[7] += 1;
if (income[i] >= 800 && income[i] <= 899)
sal_btwn[8] += 1;
if (income[i] >= 900 && income[i] <= 999)
sal_btwn[9] += 1;
if (income[i] >= 1000)
sal_btwn[10] += 1;
document.write("<br />");
i++;
var s = prompt("Enter Gross Sales of an Employee (Exit: -1):", "");
var gross = parseInt(s);
}
document.writeln("<h4>Number of sales people earned salaries in each of the following ranges:</h4>");
document.writeln("$200-$299 : " +sal_btwn[2]);
document.write("<br />");
document.writeln("$300-$399 : " +sal_btwn[3]);
document.write("<br />");
document.writeln("$400-$499 : " +sal_btwn[4]);
document.write("<br />");
document.writeln("$500-$599 : " +sal_btwn[5]);
document.write("<br />");
document.writeln("$600-$699 : " +sal_btwn[6]);
document.write("<br />");
document.writeln("$700-$799 : " +sal_btwn[7]);
document.write("<br />");
document.writeln("$800-$899 : " +sal_btwn[8]);
document.write("<br />");
document.writeln("$900-$999 : " +sal_btwn[9]);
document.write("<br />");
document.writeln(" over$1000 : " +sal_btwn[10]);
}
// -->
</script>
</head>
<body onload="calculate()">
<h1>SalesPay</h1>
<hr />

<p>Press F5 or Refresh to load script again.</p>

</body>
</html>

 

Write a function multiple that determines, for a pair of integers, whether the second integer is a multiple of the first. The function should take two integer arguments and return true if the second is a multiple of the first, and false otherwise. Incorporate this function into a script that inputs a series of pairs of integers (one pair at a time). The XHTML form should consist of two text fields and a button to initiate the calculation. The user should interact with the program by typing numbers in both text fields, then clicking the button.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>MultipleOf</title>
<script type="text/javascript">
<!--
function multiple(f1,s1)
{
if(s1 % f1 == 0)
{
document.getElementById("ans").value=true;
}
else
{
document.getElementById("ans").value=false;
}
}
// -->
</script>
</head>
<body>
<h1>MultipleOf</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to check whether Second Number is Multiple of First Number</p>
<form name = "multiply" action = "">
<table border = "1">
<caption>Multiple</caption>
<tr><td>Firt Number</td>
<td><input name = "first" type = "text" />
</td></tr>
<tr><td>Second Number</td>
<td><input name = "second" type = "text" />
</td></tr>
<tr><td>Answer</td>
<td><input name = "ans" type = "text" disabled="disabled" />
</td></tr>
<tr><td><input type = "button" value = "Calculate"
onclick = "multiple(document.multiply.first.value,document.multiply.second.value)" /></td></tr>
</table>
</form>
</body>
</html>

 

Write a script that simulates coin tossing. Let the program toss the coin each time the user clicks the Toss button. Count the number of times each side of the coin appears. Display the results. The program should call a separate function flip that takes no arguments and returns false for tails and true for heads. [Note: If the program realistically simulates the coin tossing, each side of the coin should appear approximately half the time.]

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> TossIt </title>
<script type ="text/javascript">
var toss;
var tails=0;
var heads=0;
function Toss()
{
toss = flip();
if (toss == true)
{
heads=heads+1;
document.getElementById("ans").value = "Heads";
document.getElementById("heads").value=heads;
}
else
{
tails=tails+1;
document.getElementById("ans").value= "Tails";
document.getElementById("tails").value=tails;
}
}
function flip()
{
var sides;
sides = parseInt(Math.random() * 2, 10);
if (sides == 1)
return true;
else
false;
}
</script>
</head>
<body>
<h1> TossIt</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program toss the coin each time the user clicks the Toss button</p>
<form name = "multiply" action = "">
<table border = "1">
<caption>Tossing A Coin</caption>
<tr><td>Coin Side</td>
<td><input name = "ans" type = "text" disabled="disabled" />
</td></tr>
<tr><td>Number of Heads Appear</td>
<td><input name = "heads" type = "text" disabled="disabled" />
</td></tr>
<tr><td>Number of Tails Appear</td>
<td><input name = "tails" type = "text" disabled="disabled" />
</td></tr>
<tr><td><input type = "button" value = "Toss"
onclick = "Toss()" /></td></tr>
</table>
</form>

</body>
</html>

 

Javascript Parking Garage

Posted In: . By Wasim

A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a script that calculates and displays the parking charges for each customer who parked a car in this garage yesterday. You should input from the user the hours parked for each customer. The program should display the charge for the current customer and should calculate and display the running total of yesterday's receipts. The program should use the function calculateCharges to determine the charge for each customer. Use a text input field to obtain the input from the user.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Park It </title>
<script type="text/javascript">
<!--
var total_value=0;
var pfee=0;
function calculateCharges()
{
var customer_hours = document.getElementById("hours").value;
var cust_hours=parseInt(customer_hours);
var extra_hours;
if(cust_hours <=3)
{
pfee=2;
}
else if(cust_hours > 3)
{
extra_hours = cust_hours - 3;
pfee= 2 + parseInt(extra_hours)*0.5;
if(parseInt(extra_hours) >= 16)
{
pfee=10;
}
}
document.getElementById("charge").value=pfee;
total();
}
function total()
{
total_value=total_value + pfee;
document.getElementById("total").value=total_value;
return
}
// -->
</script>
</head>
<body>
<h1>Park It</h1>
<hr />

<p>Press F5 or Refresh to load script again.</p>
<form name = "garage" action = "">
<table border = "1">
<caption>Parking Garage Charges</caption>
<tr><td>Customer Parking Hours</td>
<td><input name = "hours" type = "text" />
</td></tr>
<tr><td>Customer Charge Amount</td>
<td><input name = "charge" type = "text" disabled="disabled" />
</td></tr>
<tr><td>Running Total Receipt</td>
<td><input name = "total" type = "text" disabled="disabled" />
</td></tr>
<tr><td><input type = "button" value = "Calculate"
onclick = "calculateCharges()" /></td></tr>
</table>
</form>
</body>
</html>

 

Javascript Reversed Digits

Posted In: . By Wasim

Write a function that takes an integer value and returns the number with its digits reversed. For example, given the number 7631, the function should return 1367. Incorporate the function into a script that reads a value from the user. Display the result of the function in the status bar.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Reverse </title>
<script type="text/javascript">
<!--
function reverse()
{
var b=0;
var num = document.getElementById("digit").value;
var ans;
while(parseInt(num) > 0)
{
b= b * 10;
b= b + parseInt(num % 10)
num =parseInt(num / 10);
}
window.status="Reverse Digit:" + b;
document.getElementById("ans").value=b;
}
// -->
</script>
</head>
<body>
<h1>ReverseIt</h1>
<hr />

<p>Press F5 or Refresh to load script again. This is a program to Reverse the input numbers</p>
<form name = "multiply" action = "">
<table border = "1">
<caption>ReverseIt</caption>
<tr><td>Input Digits</td>
<td><input name = "digit" type = "text" />
</td></tr>

<tr><td>Reverse Digits</td>
<td><input name = "ans" type = "text" disabled="disabled" />
</td></tr>
<tr><td><input type = "button" value = "ReverseIt"
onclick = "reverse()" /></td></tr>
</table>
</form>
</body>
</html>

 

Javascript Guess the Number

Posted In: . By Wasim

Write a script that plays a "guess the number" game as follows: Your program chooses the number to be guessed by selecting a random integer in the range 1 to 1000. The script displays the prompt Guess a number between 1 and 1000 next to a text field. The player types a first guess into the text field and clicks a button to submit the guess to the script. If the player's guess is incorrect, your program should display Too high. Try again. or Too low. Try again. to help the player "zero in" on the correct answer and should clear the text field so the user can enter the next guess. When the user enters the correct answer, display Congratulations. You guessed the number! and clear the text field so the user can play again.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>GuessIt by Wasim</title>
<script type="text/javascript">
<!--
var num = Math.random()*(999)+1;
function Guess()
{
var guess = parseInt(document.getElementById("hint").value);
if (guess < num)
document.getElementById("guesshint").value= "No, guess higher.";
if (guess > num)
document.getElementById("guesshint").value= "No, guess lower.";
if (guess == num)
{
window.alert("Congratulations! You guessed the number");
}
}
}// -->
</script>
</head>
<body>
<h1> Guess It</h1>
<hr />

<p>Press F5 or Refresh to load script again. Guess Number</p>
<form name = "guessform" action = "">
<table border = "1">
<caption>Guess Random Number</caption>
<tr><td>Input Any Number between 1 and 1000</td>
<td><input name = "hint" type = "text" />
</td></tr>
<tr><td>Hint</td>
<td><input name = "guesshint" type = "text" disabled="disabled" />
</td></tr>
<tr><td><input type = "button" value = "Calculate" onclick= "Guess()"/></td></tr>
</table>
</form>
</body>
</html>

 

Write a script that finds the smallest of several non-negative integers. Assume that the first value read specifies the number of values to be input from the user.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Smallest Integer </title>
</head>
<body>
<h1>Smallest Integer</h1>
<hr />

<p>Press F5 or Refresh to load script again.</p>
<script type="text/javascript">
<!--
var itemcount;
var i;
var small=0;
var cal;
itemcount = window.prompt("How many inputs you wish to enter:");
var count = parseInt(itemcount);
var myarray= new Array(count);
for(i=0;i<count;i++)
{
myarray[i]= window.prompt("Enter any number:");
}
cal=myarray[0];
for(i=0;i<count;i++)
{
if(parseInt(myarray[i])< cal)
cal= myarray[i];
}

document.writeln( "<h1> Smallest of all input numbers is: " + cal + "</h1>" );
// -->
</script>
</body>
</html>

 

Javascript Star Pattern

Posted In: . By Wasim

Write a script that outputs XHTML to display the given patterns separately, one below the other. Use for statements to generate the patterns. All asterisks (*) should be printed by a single statement of the form document.write( "*" ); (this causes the asterisks to print side by side). A statement of the form document.writeln( "
" ); can be used to position to the next line. A statement of the form document.write( " " ); can be used to display a space (needed for the last two patterns). There should be no other output statements in the program. [Hint: The last two patterns require that each line begin with an appropriate number of blanks. You may need to use the XHTML

 tags.]
1.

*
**
***
****
*****
******
*******
********
*********
**********

2.
**********
*********
********
*******
******
*****
****
***
**
*


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Seeing Stars </title>
<script type = "text/javascript">
<!--
nextRow1: // target label of continue statement
for ( var row = 1; row <= 10; ++row )
{
document.writeln( "<br />" );
for ( var column = 1; column <= 10; ++column )
{
if ( column > row )
continue nextRow1; // next iteration of
// labeled loop
document.write( "* " );
}
}
document.writeln( "<br />" );
nextRow:
for ( var row = 1; row <= 10; ++row )
{
document.writeln( "<br />" );
for ( var column = 10; column >= 1; column-- )
{
if ( column < row )
continue nextRow; // next iteration of
// labeled loop
document.write( "* " );
}
}
nextRow2:
for ( var row = 1; row <= 10; ++row )
{
document.writeln( "<br />" );
for(var space=0; space<10; space++)
{
document.write("&nbsp;");
}
for ( var column = 10; column >= 1; column-- )
{
if ( column < row )
continue nextRow2; // next iteration of
// labeled loop
document.write( "*" );
}
}
// -->
</script>
</head>
<body>
<h1><center>Seeing Stars </center>
<hr />
<p> Click Refresh(F5) or reload to run this script again</p>
</body>
</html>

 

Javascript Multiply It

Posted In: . By Wasim

Write a script that calculates the product of the odd integers from 1 to 15 then outputs XHTML text that displays the results.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Multiply It </title>
</head>
<body>
<h1> Multiply It </h1>
<hr />

<p>Press F5 or Refresh to load script again.</p>
<script type="text/javascript">
<!--
var number;
var i;
var ans=1;
number = window.prompt("Enter any odd number between 1 and 35:");
var count = parseInt(number);
if(count % 2 == 0)
{
document.writeln( "<h1> Your input number " + number + " is not an odd number</h1>" );
}
else if(count >= 1 && count <= 35)
{
for(i=1;i<=count;i=i+1)
{
ans=ans*i;
}
document.writeln( "<h1> The product of 1 to " + number + " is: " + ans + "</h1>" );
}
else
{
document.writeln( "<h1> Input Odd number " + number + " doesn't seems to be in range between 1 and 35 </h1>" );
}

// -->
</script>

</body>
</html>

 

Javascript Mail Order

Posted In: . By Wasim

A mail-order house sells five different products whose retail prices are as follows: product 1, $2.98; product 2, $4.50; product 3, $9.98; product 4, $4.49; and product 5, $6.87. Write a script that reads a series of pairs of numbers as follows:

1. Product number
2. Quantity sold for one day

Your program should use a switch statement to determine each product's retail price and should calculate and output XHTML that displays the total retail value of all the products sold last week. Use a prompt dialog to obtain the product number and quantity from the user. Use a sentinel-controlled loop to determine when the program should stop looping and display the final results.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Mail Order </title>
<script type="text/javascript">
<!--
var q;
var p;
var qty;
var price;
var pno=0;
var ans=0;
var counter=0;
total=0;
document.write("Enter product number for an item, -1 to quit: <br /> 1. Product-1 <br /> 2. Product-2 <br /> 3. product-3 <br /> 4. Product-4 <br /> 5. Product-5");
pno=window.prompt("Enter product number, -1 to Quit");
p=parseInt(pno);
while(pno!=-1)
{
switch(p)
{
case 1: price= 2.98;
q= window.prompt("Enter number of quantities sold for product-1:");
qty=parseInt(q);
ans=price*qty;
break;
case 2: price= 4.50;
q= window.prompt("Enter number of quantities sold for product-2:");
qty=parseInt(q);
ans=price*qty;
break;
case 3: price= 9.98;
q= window.prompt("Enter number of quantities sold for product-3:");
qty=parseInt(q);
ans=price*qty;
break;
case 4: price= 4.49;
q= window.prompt("Enter number of quantities sold for product-4:");
qty=parseInt(q);
ans=price*qty;
break;
case 5: price= 6.87;
q= window.prompt("Enter number of quantities sold for product-5:");
qty=parseInt(q);
ans=price*qty;
break;
default: window.alert("No proper input, Please try Again");
break;
}
counter=counter+1;
total=total + parseInt(ans);
pno=window.prompt("Enter product number, -1 to Quit");
p=parseInt(pno);
}
if(counter!=0)
{
document.writeln( "<h1> Total Sales for Last week is: $" + total + "</h1>" );
}
else
{
window.alert("No product number is entered, Thank you");
}
// -->
</script>
</head>
<body>
<h1>Mail Order</h1>
<hr />

<p>Press F5 or Refresh to load script again.</p>

</body>
</html>

 

Javascript Pay Day

Posted In: . By Wasim

Develop a JavaScript program that will determine the gross pay for each of three employees. The company pays "straight time" for the first 40 hours worked by each employee and pays "time and a half" for all hours worked in excess of 40 hours. You are given a list of the employees of the company, the number of hours each employee worked last week and the hourly rate of each employee. Your program should input this information for each employee, determine the employee's gross pay and output XHTML text that displays the employee's gross pay. Use prompt dialogs to input the data.


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Pay Day </title>
<script type="text/javascript">
<!--
var e1;
var r1;
var e2;
var r2;
var e3;
var r3;
e1 = window.prompt("Enter Number of Hours Employee1 worked last week:");
r1 = window.prompt("Enter hourly wage rate for Employee1:");
e2 = window.prompt("Enter Number of Hours Employee2 worked last week:");
r2 = window.prompt("Enter hourly wage rate for Employee2:");
e3 = window.prompt("Enter Number of Hours Employee3 worked last week:");
r3 = window.prompt("Enter hourly wage rate for Employee3:");
var cal1;
if(parseInt(e1)>40)
{
var extrahours = parseInt(parseInt(e1)-40);
var extrarate= parseInt(r1) + (parseInt(r1) / 2 );
cal1= ((40 * parseInt(r1))+ (extrahours * parseInt(extrarate)));
}
else
{
cal1=parseInt(e1) * parseInt(r1);
}
document.writeln( "<h1> Employee1 Gross Wage is: " + cal1 + "</h1>" );
var cal2;
if(parseInt(e2)>40)
{
var extrahours1 = parseInt(parseInt(e2)-40);
var extrarate1= parseInt(r2) + (parseInt(r2) / 2 );
cal2= ((40 * parseInt(r2))+ (extrahours1 * parseInt(extrarate1)));
}
else
{
cal2=parseInt(e2) * parseInt(r2);
}
document.writeln( "<h1> Employee2 Gross Wage is: " + cal2 + "</h1>" );
var cal3;
if(parseInt(e3)>40)
{
var extrahours2 = parseInt(parseInt(e3)-40);
var extrarate2= parseInt(r3) + (parseInt(r3) / 2 );
cal3= ((40 * parseInt(r3))+ (extrahours2 * parseInt(extrarate2)));
}
else
{
cal3=parseInt(e3) * parseInt(r3);
}
document.writeln( "<h1> Employee3 Gross Wage is: " + cal3+ "</h1>" );
// -->
</script>
</head>
<body>
<h1><center>Pay Day</center>
<hr />
<p> Click Refresh(F5) or reload to run this script again</p>
</body>
</html>

 

Javascript Palindrome

Posted In: . By Wasim

A palindrome is a number or a text phrase that reads the same backward and forward. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a script that reads in a five-digit integer and determines whether it is a palindrome. If the number is not five digits long, display an alert dialog indicating the problem to the user. Allow the user to enter a new value after dismissing the alert dialog. [Hint: It is possible to do this exercise with the techniques learned in this chapter. You will need to use both division and remainder operations to "pick off" each digit.]

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title> Palindrome </title>
<script type="text/javascript">
<!--
var number;
number = window.prompt("Enter any 5 Digit number:");
var n = parseInt(number);
while(n<10000 n > 99999 )
{
window.alert("The Number is not a five digit number");
number = window.prompt("Enter any 5 Digit number:");
n = parseInt(number);
}
var digit1 = n%10;
n = n/10;
var digit2 = n%10;
n = n/10;
var digit3 = n%10;
n = n/10;
var digit4 = n%10;
var digit5 = n/10;
if(parseInt(digit1)==parseInt(digit5))
{
if(parseInt(digit2)==parseInt(digit4))
{
document.writeln( "<h1>" + number + " is a Palindrome </h1>" );
}
}
else
{
document.writeln( "<h1>" + number + " is not a Palindrome </h1>" );
}
// -->
</script>
</head>
<body>
<h1> Palindrome </h1>
<hr />
<p> Click Refresh(F5) or reload to run this script again</p>


</body>
</html>

 

Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording the number of miles driven and the number of gallons used for each tankful. Develop a JavaScript program that will take as input the miles driven and gallons used (both as integers) for each tankful. The program should calculate and output XHTML text that displays the number of miles per gallon obtained for each tankful and prints the combined number of miles per gallon obtained for all tankfuls up to this point. Use prompt dialogs to obtain the data from the user.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Mileage</title>
<script type="text/javascript">
<!--
var g1;
var m1;
var a1;
var a2;
var a3;
var g2;
var m2;
var g3;
var m3;
var avgall;
g1 = window.prompt("Enter Number of Gallons used for Tank1:");
m1 = window.prompt("Enter number of miles drived for Tank1:");
g2 = window.prompt("Enter Number of Gallons used for Tank2:");
m2 = window.prompt("Enter number of miles drived for Tank2:");
g3 = window.prompt("Enter Number of Gallons used for Tank3:");
m3 = window.prompt("Enter number of miles drived for Tank3:");
a1 = parseInt(m1) / parseInt(g1);
a2 = parseInt(m2) / parseInt(g2);
a3 = parseInt(m3) / parseInt(g3);
avgall = ((parseInt(m1) + parseInt(m2) + parseInt(m3)) / (parseInt(g1) + parseInt(g2) + parseInt(g3)));
document.writeln( "<h1> Miles per Gallon for Tank1 is: " + a1 + "</h1>" );
document.writeln( "<h1> Miles per Gallon for Tank2 is: " + a2 + "</h1>" );
document.writeln( "<h1> Miles per Gallon for Tank3 is: " + a3 + "</h1>" );
document.writeln( "<h1> Combined Miles per Gallon for all Tank is: " + avgall + "</h1>" );
// -->
</script>
</head>
<body>
<h1><center>Mileage Calculation</center>
<hr />
<p> Click Refresh(F5) or reload to run this script again</p>
</body>
</html>

 

Javascript Commission

Posted In: . By Wasim

A large company pays its salespeople on a commission basis. The salespeople receive $200 per week, plus 9 percent of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9 percent of $5000, or a total of $650. You have been supplied with a list of the items sold by each salesperson. The values of these items are as follows:
Item Value
1 239.99
2 129.75
3 99.95
4 350.89
Develop a program that inputs one salesperson's items sold for last week, calculates the salesperson's earnings and outputs XHTML text that displays the salesperson's earnings.


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Commission</title>
<script type="text/javascript">
<!--
var itemcount;
var i;
var sum=0;
var cal;
itemcount = window.prompt("How many item/items Salesman sale last week:");
var count = parseInt(itemcount);
for(i=0;i<count;i++)
{
cal = window.prompt("Enter item number:");
var getprice = parseInt(cal);
if(getprice == 1)
{
sum = sum + 239.99;
}
else if(getprice == 2)
{
sum = sum + 129.75;
}
else if(getprice == 3)
{
sum = sum + 99.95;
}
else if(getprice == 4)
{
sum = sum + 350.89;
}
else
{
window.alert("There is no such Item Number exists, Please try again");
exit();
}
}
var sal= 200 + (( 9 / 100)* parseInt(sum));
document.writeln( "<h1> Total Salary for this salesperson is: " + sal + "</h1>" );
// -->
</script>
</head>
<body>
<h1>Commission</h1>
<hr />

<p>Press F5 or Refresh to load script again.</p>
</body>
</html>

 


Write a script that outputs XHTML text that displays in the XHTML document a checkerboard pattern, as follows:


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Checkerboard</title>
<script type="text/javascript">
<!--
var i = 1;
var j = 1;
for ( i = 1; i<=8; i ++)
{
for ( j = 1; j<=8; j++)
{
document.write("* ");
}
document.write("<br />");
if(i%2)
{
document.write("&nbsp;");
}
}
// -->
</script>
</head>
<body>
<h1> Checkerboard Program </h1>
<hr />
<p> Click Refresh(F5) or reload to run this script again </p>
</body>
</html>

 

Write a script that takes three integers from the user and displays the sum, average, product, smallest and largest of the numbers in an alert dialog.

<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Exercise 6.18 Three Digit Math </title>
<script type="text/javascript">
<!--
var firstnum;
var secondnum;
var flag = 0;
firstnum = window.prompt("Enter any Integer Value:");
secondnum = window.prompt("Enter any second Integer Value:");
thirdnum = window.prompt("Enter any third Integer Value:");
var first = parseInt(firstnum);
var second = parseInt(secondnum);
var third = parseInt(thirdnum);
var sum = first + second + third;
var avg = (first + second + third) / 3;
var prod= first * second * third;
if(first>=second && first>=third)
{
if(second>third)
{
window.alert( " SUM: " + sum + "\n Average: " + avg + "\n Product: " + prod + "\n" + third + " is the smallest number" + "\n" + first + " is the largest of all three numbers" );
}
else
{
window.alert( " SUM: " + sum + "\n Average: " + avg + "\n Product: " + prod + "\n" + second + " is the smallest number" + "\n" + first + " is the largest of all three numbers" );
}
}
else if(second>=first && second>=third)
{
if(first>third)
{
window.alert( " SUM: " + sum + "\n Average: " + avg + "\n Product: " + prod + "\n" + third + " is the smallest number" + "\n" + second + " is the largest of all three numbers" );
}
else
{
window.alert( " SUM: " + sum + "\n Average: " + avg + "\n Product: " + prod + "\n" + first + " is the smallest number" + "\n" + second + " is the largest of all three numbers" );
}
}
else if(third>=first && third>=second)
{
if(first>second)
{
window.alert( " SUM: " + sum + "\n Average: " + avg + "\n Product: " + prod + "\n" + second + " is the smallest number" + "\n" + third + " is the largest of all three numbers" );
}
else
{
window.alert( " SUM: " + sum + "\n Average: " + avg + "\n Product: " + prod + "\n" + first + " is the smallest number" + "\n" + third + " is the largest of all three numbers" );
}
}
// -->
</script>
</head>
<body>
</body>
</html>

 

Write a script that asks the user to enter two integers, obtains the numbers from the user and outputs text that displays the larger number followed by the words "is larger" in an alert dialog. If the numbers are equal, output XHTML text that displays the message "These numbers are equal."


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Exercise 6.17 Compare Them</title>
<script type="text/javascript">
<!--
var firstnum;
var secondnum;
firstnum = window.prompt("Enter any Integer Value:");
secondnum = window.prompt("Enter any second Integer Value:");
var first = parseInt(firstnum);
var second = parseInt(secondnum);
if(first>second)
{
window.alert( first + " is Larger than " + second );
}
else if(second>first)
{
window.alert( second + " is Larger than " + first );
}
else
{
window.alert( first + " is equal to " + second );
}
// -->
</script>
</head>
<body>
</body>
</html>

 

Write a script that gets from the user the radius of a circle and outputs XHTML text that displays the circle's diameter, circumference and area. Use the constant value 3.14159 for π. Use the GUI techniques shown in Fig. 6.9. [Note: You may also use the predefined constant Math.PI for the value of π. This constant is more precise than the value 3.14159. The Math object is defined by JavaScript and provides many common mathematical capabilities.] Use the following formulas (r is the radius): diameter = 2r, circumference = 2πr, area = πr 2.


<?xml version = "1.0" encoding = "utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Exercise 6.19 Circle It</title>
<script type="text/javascript">
<!--
var radius;
radius = window.prompt("Enter Radius of a circle:");
var r = parseInt(radius);
var d = 2 * r;
var circum= 2 * 3.14159 * r;
var area = Math.PI * r * r;
document.writeln( "<h1> The Diameter of a cirlce is: " + d + "</h1>" );
document.writeln("<h1> The Circumference: " + circum + "</h1>");
document.writeln("<h1> The Area of a cirlce is: " + area + "</h1>");
// -->
</script>


</head>
<body>
<p> Click Refresh(F5) or reload to run this script again</p>

</body>
</html>

 



Today, T-Mobile officially released the rumored Samsung Behold and Samsung Gravity. The Behold has a large touchscreen display while the Gravity has a sliding QWERTY keyboard.
Touchscreen
Samsung T919 Behold looks like the Samsung F480 but on steroids. On top of the touchscreen TouchWiz interface, 5 megapixel autofocus camera, 3G support, full HTML browser the new Behold scores higher with its built-in GPS. Unfortunately, even the Behold does not feature the highly desirable Wi-Fi feature.

Samsung Behold can be yours starting from November 10 for $149.99 on a 2 year contract in light rose color.

Feature

Real web browsing*
Get more pages and better Web content delivered efficiently to your phone.
3G
T-Mobile’s high-speed 3G data network delivers the ultimate mobile Web experience in several metropolitan areas
5 Megapixel Camera
With quality worth printing, now you can really enjoy those special moments captured on your phone. You can also share them with family and friends by sending them to any e-mail address, T-Mobile camera phone, or MyAlbum.
Music player
Play your favorite music wherever you are.
Video capture/playback
Capture and play back short video clips.
Stereo Bluetooth® wireless technology
Connect your phone to your computer or stereo headset without any wires.
Picture messaging*
Send pictures from your phone to others.
Text messaging*
The quick, quiet way to stay connected.
Voice dialing
Call someone with simple voice commands to keep your hands free for activities like driving.
myFaves capable*
Get unlimited any-network calling to any 5 people with a myFaves plan.
Address book
The info you need to contact your contacts.
Calculator
A handy way to check your figures.
Calendar
Keep track of appointments and even set reminders to make sure you're on time.
Alarm clock
Handy reminders help you stay on schedule.
Micro SD memory standard
Easily take the memory card out of your device to transfer files and data to another device.
HiFi Ringers™, MegaTones®, Wallpapers*
Download sounds and voices from your favorite artists, instrumental versions of songs, and wallpapers.
Speaker phone
Put down the phone and keep talking with a convenient speakerphone.
Vibrating alert
Phone vibrates to let you know you have a call or message without disturbing anyone.


 

Privacy in Technology

Posted In: . By Wasim

What is Privacy?
Privacy is the claim of individuals, groups or institutions to determine for themselves when, how, and to what extent information about them is communicated to others.

Ways to Protect Privacy
• There are two basic ways to protect privacy:
1. Technology
2. Law

Privacy for end users
1. Who’s watching you?
2. Why?
3. What can I do?

Current Privacy Options
1. Share Nothing
2. Share Everything
3. Manage a crowd

Types of Privacy Harms
1. Intrusions
2. Information collection
3. Information processing

The attacks of Sept. 11 left us with a terrible Vulnerability on human, world's computers, networks, and information systems.

What is Internet Privacy?
The ability to control what information one reveals about oneself over the Internet, and to control who can access that information.
Protecting Your Online Privacy
1. Look for privacy policies on the web
2. Clear your cache memory browsing.
3. Encrypt your E-mail
4. Get a separate email account for personal email and work email.
5. Use anonymizers while browsing.

Security Issues
Data should be secure and accurate – Without security, can have good privacy policies but hackers gain entry – Without accuracy, wrong decisions are made about individuals.

 

There are approximately 30,000 hacker-oriented websites that disclose hacker know-how and tips on how to create computer viruses or “bugs.” One virus, the Manila-generated “Love Bug,” virtually circumnavigated the globe in twelve hours, illustrating that a teenager with Internet access in an underdeveloped nation can wreak as much cyberspace havoc as a privileged teenager in a developed nation.

Computer N/w Infrastructure Weakness and Vulnerabilities

The regular 3-way TCP\IP Handshake has been depicted below:
1. Client---------SYN Packet-------------Host
2. Host-----------SYN\ACK Packet--------Clien
3. Client----------ACK Packet---------------Host
The Three way handshake established the trust relationship between the client and the host.

IP Spoofing
Spoofing is the creation of TCP/IP packets using somebody else's IP address. Routers use the "destination IP" address in order to forward packets through the Internet, but ignore the "source IP" address. That address is only used by the destination machine when it responds back to the source.

TCP SYN ATTACK
Also known as ‘Half Open Scanning’ because only half of the complete 3-way TCP\IP connection is established.
Client-----SYN Packet--- Host
Case I: (Open) Host-----SYN\ACK Packet-- Client
Case 2: (Closed) Host----RST\ACK Packet---- Client

In this attack the client continually sends and receives the ACK packets but it does not open the session. The server holds these sessions open, awaiting the final packet in the sequence. This cause the server to fill up the available connections and denies any requesting clients access.

TCP Sequence Number Attack
This is when the attacker takes control of one end of a TCP session. The goal of this attack is to kick the attacked end of the network for the duration of the session. Only then will the attack be successful. Each time a TCP message is sent the client or the server generates a sequence number. The attacker intercepts and then responds with a sequence number similar to the one used in the original session. This attack can then hijack or disrupt a session. If a valid sequence number is guessed the attacker can place himself between the client and the server. The attacker gains the connection and the data from the legitimate system. The only defense of such an attack is to know that it’s occurring

Distributed Denial of Service Attacks (DDoS)

A distributed denial of service attack (DDOS) is one in which an attacker first compromises a number of hosts, and installs a daemon on those hosts. At a later point, the attacker sends a request to the daemon on the compromised hosts asking it to begin flooding a target host with various types of packets.

Ping of Death Attack
Ø The maximum packet size allowed to be transmitted by TCP\IP on a network is 65 536 bytes.
Ø In the Ping of Death Attack, a packet having a size greater than this maximum size allowed by TCP\IP is sent to the target system.
Ø As soon as the target system receives a packet exceeding the allowable size, then it crashes, reboots or hangs.
Ø This attack can easily be executed by the ‘ping’ command as follows:
ping -l 65540 hostname

Smurf Attacks
1. In SMURF Attacks, a huge number of Ping Requests are sent to the Target system, using Spoofed IP Addresses from within the target network.
2. Due to infinite loops thus generated and due to the large number of Ping Requests, the target system will crash, restart or hang up.

Tear Drop Attack
Data sent from the source to the destination system, is broken down into smaller fragments at the source system and then reassembled into larger chunks at the destination system.
For Example:
Say data of 4000 bytes is to be sent across a network, then it is broken down into three chunks:
CHUNK A contains Bytes 1 to 1500.
CHUNK B contains Bytes 1501 to 3000
CHUNK C contains Bytes 3001 to 4000
1. In this example the range of CHUNK A is 1 to 1500, range of CHUNK B is 1501 to 3000 while the range of CHUNK C is 3001 to 4000.
2. However, in case of a Teardrop attack, these ranges of data chunks are overlapping. For Example, in case of a Teardrop attack, the same 4000 bytes would be broken down into the below three chunks:
CHUNK A contains Bytes 1 to 1500.
CHUNK B contains Bytes 1499 to 3000
CHUNK C contains Bytes 2999 to 4000
3. In this example the range of CHUNK A is 1 to 1500; range of CHUNK B is 1499 to 3000 while the range of CHUNK C is 2999 to 4000. Thus, the ranges are overlapping.
4. Since here the ranges are overlapping, the target system gets DOS!!!

Windows NT Registry Threats
Common NT Registry attacks include the L0pht Crack, the Chargen Attack, the SSPing/ JOLT, and the Red Button.

 

Sponsored Ads