Ads

Pages

Monday, January 3, 2011

CS101 Assignment 03 Solution

VUsolutions

<>

<>

< language="JavaScript" type="text/javascript">

function alert_showmsg(msgs)

{

var whole_msg="";

var first_elmnt=null;

for(var m=0;m <>

{

if(null == first_elmnt)

{

first_elmnt = msgs[m]["input_element"];

}

whole_msg += msgs[m]["msg"] + "\n";

}

alert(whole_msg);

if(null != first_elmnt)

{

sfm_set_focus(first_elmnt);

}

}

function sfm_validator_enable_focus(enable)

{

document.set_focus_onerror = enable;

}

function set_addnl_vfunction(functionname)

{

this.formobj.addnlvalidation = functionname;

}

function sfm_set_focus(objInput)

{

if(document.set_focus_onerror)

{

objInput.focus();

}

}

function sfm_enable_show_msgs_together()

{

this.show_errors_together=true;

this.formobj.show_errors_together=true;

}

function clear_all_validations()

{

for(var itr=0;itr <>

{

this.formobj.elements[itr].validationset = null;

}

}

function form_submit_handler()

{

var bRet = true;

document.error_disp_handler.clear_msgs();

for(var itr=0;itr <>

{

if(this.elements[itr].validationset &&

!this.elements[itr].validationset.validate())

{

bRet = false;

}

if(!bRet && !this.show_errors_together)

{

break;

}

}

if(this.addnlvalidation)

{

str =" var ret = "+this.addnlvalidation+"()";

eval(str);

if(!ret)

{

bRet=false;

}

}

if(!bRet)

{

document.error_disp_handler.FinalShowMsg();

return false;

}

return true;

}

function Validator(frmname)

{

this.formobj=document.forms[frmname];

if(this.formobj.onsubmit)

{

this.formobj.old_onsubmit = this.formobj.onsubmit;

this.formobj.onsubmit=null;

}

else

{

this.formobj.old_onsubmit = null;

}

this.formobj._sfm_form_name=frmname;

this.formobj.onsubmit=form_submit_handler;

this.ValAddition = add_validation;

this.setAddnlValidationFunction=set_addnl_vfunction;

this.clearAllValidations = clear_all_validations;

this.disable_validations = false;//new

document.error_disp_handler = new sfm_ErrorDisplayHandler();

this.EnableOnPageErrorDisplay=validator_enable_OPED;

this.EnableOnPageErrorDisplaySingleBox=validator_enable_OPED_SB;

this.show_errors_together=true;

this.EnableMsgsTogether=sfm_enable_show_msgs_together;

document.set_focus_onerror=true;

this.EnableFocusOnError=sfm_validator_enable_focus;

}

function add_validation(itemname,descriptor,errstr)

{

var condition = null;

if(arguments.length > 3)

{

condition = arguments[3];

}

if(!this.formobj)

{

alert("Error: The form object is not set properly");

return;

}//if

var itemobj = this.formobj[itemname];

if(itemobj.length && isNaN(itemobj.selectedIndex) )

//for radio button; don't do for 'select' item

{

itemobj = itemobj[0];

}

if(!itemobj)

{

alert("Error: Couldnot get the input object named: "+itemname);

return;

}

if(!itemobj.validationset)

{

itemobj.validationset = new ValidationSet(itemobj,this.show_errors_together);

}

itemobj.validationset.add(descriptor,errstr,condition);

itemobj.validatorobj=this;

}

function validator_enable_OPED()

{

document.error_disp_handler.EnableOnPageDisplay(false);

}

function validator_enable_OPED_SB()

{

document.error_disp_handler.EnableOnPageDisplay(true);

}

function edh_clear_msgs()

{

this.msgdisplay.clearmsg(this.all_msgs);

this.all_msgs = new Array();

}

function edh_FinalShowMsg()

{

this.msgdisplay.showmsg(this.all_msgs);

}

function edh_EnableOnPageDisplay(single_box)

{

if(true == single_box)

{

this.msgdisplay = new SingleBoxErrorDisplay();

}

else

{

this.msgdisplay = new DivMsgDisplayer();

}

}

function edh_ShowMsg(msg,input_element)

{

var objmsg = new Array();

objmsg["input_element"] = input_element;

objmsg["msg"] = msg;

this.all_msgs.push(objmsg);

}

function AlertMsgDisplayer()

{

this.showmsg = alert_showmsg;

this.clearmsg=alert_clearmsg;

}

function sfm_ErrorDisplayHandler()

{

this.msgdisplay = new AlertMsgDisplayer();

this.EnableOnPageDisplay= edh_EnableOnPageDisplay;

this.ShowMsg=edh_ShowMsg;

this.FinalShowMsg=edh_FinalShowMsg;

this.all_msgs=new Array();

this.clear_msgs=edh_clear_msgs;

}

function alert_clearmsg(msgs)

{

}

function sfm_show_error_msg(msg,input_elmt)

{

document.error_disp_handler.ShowMsg(msg,input_elmt);

}

function SingleBoxErrorDisplay()

{

this.showmsg=sb_div_showmsg;

this.clearmsg=sb_div_clearmsg;

}

function sb_div_clearmsg(msgs)

{

var divname = form_error_div_name(msgs);

show_div_msg(divname,"");

}

function ValidationDesc(inputitem,desc,error,condition)

{

this.desc=desc;

this.error=error;

this.itemobj = inputitem;

this.condition = condition;

this.validate=vdesc_validate;

}

function vdesc_validate()

{

if(this.condition != null )

{

if(!eval(this.condition))

{

return true;

}

}

if(!validateInput(this.desc,this.itemobj,this.error))

{

this.itemobj.validatorobj.disable_validations=true;

sfm_set_focus(this.itemobj);

return false;

}

return true;

}

function ValidationSet(inputitem,msgs_together)

{

this.vSet=new Array();

this.add= add_validationdesc;

this.validate= vset_validate;

this.itemobj = inputitem;

this.msgs_together = msgs_together;

}

function add_validationdesc(desc,error,condition)

{

this.vSet[this.vSet.length]=

new ValidationDesc(this.itemobj,desc,error,condition);

}

function vset_validate()

{

var bRet = true;

for(var itr=0;itr

{

bRet = bRet && this.vSet[itr].validate();

if(!bRet && !this.msgs_together)

{

break;

}

}

return bRet;

}

function TestRequiredInput(objValue,strError)

{

var ret = true;

var val = objValue.value;

val = val.replace(/^\s+|\s+$/g,"");//trim

if(eval(val.length) == 0)

{

if(!strError || strError.length ==0)

{

strError = objValue.name + " : Required Field";

}//if

sfm_show_error_msg(strError,objValue);

ret=false;

}//if

return ret;

}

function TestMaxLen(objValue,strMaxLen,strError)

{

var ret = true;

if(eval(objValue.value.length) > eval(strMaxLen))

{

if(!strError || strError.length ==0)

{

strError = objValue.name + " : "+ strMaxLen +" characters maximum ";

}//if

sfm_show_error_msg(strError,objValue);

ret = false;

}//if

return ret;

}

function TestMinLen(objValue,strMinLen,strError)

{

var ret = true;

if(eval(objValue.value.length) < eval(strMinLen))

{

if(!strError || strError.length ==0)

{

strError = objValue.name + " : " + strMinLen + " characters minimum ";

}//if

sfm_show_error_msg(strError,objValue);

ret = false;

}//if

return ret;

}

function TestInputType(objValue,strRegExp,strError,strDefaultError)

{

var ret = true;

var charpos = objValue.value.search(strRegExp);

if(objValue.value.length > 0 && charpos >= 0)

{

objValue.style.background="lightblue";

if(!strError || strError.length ==0)

{

strError = strDefaultError;

}//if

sfm_show_error_msg(strError,objValue);

ret = false;

}//if

return ret;

}

function TestLessThan(objValue,strLessThan,strError)

{

var ret = true;

if(isNaN(objValue.value))

{

sfm_show_error_msg(objValue.name +": Should be a number ",objValue);

ret = false;

}//if

else

if(eval(objValue.value) >= eval(strLessThan))

{

if(!strError || strError.length ==0)

{

strError = objValue.name + " : value should be less than "+ strLessThan;

}//if

objValue.style.background="lightblue";

sfm_show_error_msg(strError,objValue);

ret = false;

}//if

return ret;

}

function TestGreaterThan(objValue,strGreaterThan,strError)

{

var ret = true;

if(isNaN(objValue.value))

{

sfm_show_error_msg(objValue.name+": Should be a number ",objValue);

ret = false;

}//if

else

if(eval(objValue.value) <= eval(strGreaterThan))

{

if(!strError || strError.length ==0)

{

strError = objValue.name + " : value should be greater than "+ strGreaterThan;

}//if

objValue.style.background="lightblue";

sfm_show_error_msg(strError,objValue);

ret = false;

}//if

return ret;

}

function CheckBtwValues(objValue,strGrtVal,strError)

{

var ret = true;

if(isNaN(objValue.value))

{

sfm_show_error_msg(objValue.name+": Should be a number ",objValue);

ret = false;

}//if

else

if(objValue.value == '')

{

strError = "Please enter a GPA number only.";

fldColor = "yello";

}//if

else

if(eval(objValue.value) >= 1 && eval(objValue.value) <>

{

strError = "FAIR - YOU HAVE GOT D GRADE.";

fldColor = "green";

}//if

else

if(eval(objValue.value) >= 2 && eval(objValue.value) <>

{

strError = "GOOD - YOU HAVE GOT C GRADE.";

fldColor = "green";

}//if

else

if(eval(objValue.value) >= 3 && eval(objValue.value) <>

{

strError = "VERY GOOD - YOU HAVE GOT B GRADE.";

fldColor = "green";

}//if

if(eval(objValue.value) == 4)

{

strError = "EXCELLENT - YOU HAVE GOT A GRADE.";

fldColor = "green";

}//if

objValue.style.background=fldColor;

sfm_show_error_msg(strError,objValue);

ret = false;

return ret;

}

function validateInput(strValidateStr,objValue,strError)

{

var ret = true;

var epos = strValidateStr.search("=");

var command = "";

var cmdvalue = "";

if(epos >= 0)

{

command = strValidateStr.substring(0,epos);

cmdvalue = strValidateStr.substr(epos+1);

}

else

{

command = strValidateStr;

}

switch(command)

{

case "req":

case "required":

{

ret = TestRequiredInput(objValue,strError)

break;

}//case required

case "maxlength":

case "maxlen":

{

ret = TestMaxLen(objValue,cmdvalue,strError)

break;

}//case maxlen

case "minlength":

case "minlen":

{

ret = TestMinLen(objValue,cmdvalue,strError)

break;

}//case minlen

case "dec":

case "decimal":

{

ret = TestInputType(objValue,"[^0-9\.]",strError,

"Enter numbers only");

break;

}

case "lt":

case "lessthan":

{

ret = TestLessThan(objValue,cmdvalue,strError);

break;

}

case "gt":

case "greaterthan":

{

ret = TestGreaterThan(objValue,cmdvalue,strError);

break;

}//case greaterthan

case "CheckGPA":

{

ret = CheckBtwValues(objValue,strError);

break;

}

}//switch

return ret;

}

<>

< align="center">YOUR STUDENT ID :: Assignment NUMBER

< action="http://www.vu.edu.pk" method="post" id="cs101frm">

< width="800" border="1" align="center">

<>

< width="116" height="50" align="center" bgcolor="#CCCCCC">GPA

< width="468" bgcolor="#CCCCCC">< name="GPA" type="text" id="GPA" size="75">

<>

< height="50" bgcolor="#CCCCCC">

< bgcolor="#CCCCCC">< type="submit" name="button" id="button" value="Find Grade">

Mgt602 Assignment No. 2 Announcement

Assignment 02

Dated: Jan 03, 11

Semester “Fall 2010” “Entrepreneureship (MGT602)”

This is to inform that next Assignment (covering video lecture no. 1 to lecture no 30) will be uploaded on VULMS according to the following schedule

Schedule

Opening Date and Time

January 05, 2011 At 12:01 A.M. (Mid-Night)

Closing Date and Time

January 10, 2011 At 11:59 P.M. (Mid-Night)

Note: Only in the case of Assignment, 24 Hrs extra / grace period after the above mentioned due date is usually available to overcome uploading difficulties which may be faced by the students on last date. This extra time should only be used to meet the emergencies and above mentioned due dates should always be treated as final to avoid any inconvenience.

Important:

1. For acquiring the relevant knowledge, do not rely only on handouts but watch the course video lectures, which can be downloaded for free from Online VU Lectures, and also use other reference books.

Mgt501 Assignment No. 2

Most of the practices of the Human Resource Management are interlinked and have a profound impact on one another. The prosperity of organizations rests upon the skills of its employees. If an organization wants to prosper, it needs to take into account the existing skills of the employees and take measures to get them match with the needs of the technology. While investing in employees, the organization actually invests in it’s self. Or the development of organization is subject to the investment in its employees.

Elaborate how the investigation of skills and investment in employees can lead to the development of the organization. Word limit: 500 words

Mgt201 GDB Solution

“Discussion Question”

Given a risk-free rate of 8 percent and a market risk premium of 9.5 percent, based on the betas given in the following table:

Security Beta
A 0.95

B 1.25

1. Calculate required rate of return of each stock?
2. If Ahmed is a risk lover investor, he will prefer to invest in which stock?
3. As against it, Shahzad is a risk averse investor; he will prefer to invest in which stock?

Solution:

Required rate of return for A

Rce = rRF + (rM – rRF) (beta)
Rce = 0.08 + (0.095 – 0.08)(0.95)
Rce = 0.08+(0.015)(0.95)
Rce = 0.08 + 0.01425
Rce = 0.09425 *100
Rce = 9.425%

Required rate of return for B
Rce = rRF + (rM – rRF) (beta)
Rce = 0.08 + (0.095 – 0.08)(1.25)
Rce = 0.08+(0.015)(1.25)
Rce = 0.08 + 0.01875
Rce = 0.09875 *100
Rce = 9.875%

A risk loving person will buy if OR > 1 or = 1, but he might also buy when OR is < 1.
The degree of risk aversion increases as your income level falls, due to diminishing marginal
utility of income.

As Ahmad is Risk Lover he will like to invest in Stock B because it has Beta More Than 1 as 1.25


A risk averse person will not buy if OR < 1. He will also not buy if OR = 1. He might also not
decide to buy if OR > 1.

As Shahzad is risk averse so he will invest in Stock A because it has Beta Less Than 1 as 0.9

Friday, December 31, 2010

IT430 Assignment # 2 Solution

What are the steps involved in symmetric cryptography? Also explain key management in conventional cryptography using some example.
Solution:-
Symmetric Cryptography
With symmetric cryptography, both the sender and recipient share a key that is used to perform both encryption and decryption. Symmetric cryptography is commonly used to perform encryption. It also provides data integrity when symmetric keys are used in conjunction with other algorithms to create Message Authentication Codes (MACs). For more information about MACs, see Data Origin Authentication in Chapter 2, "Message Protection Patterns."
Figure 1 illustrates the process of encrypting and decrypting data with a shared secret key.



Figure 1. The process of symmetric encryption

As illustrated in Figure 1,
symmetric encryption involves the following steps:
The sender creates a ciphertext message by encrypting the plaintext message with a symmetric encryption algorithm and a shared key.
The sender sends the ciphertext message to the recipient.
The recipient decrypts the ciphertext message back into plaintext with a shared key.

Numerous symmetric algorithms are currently in use. Some of the more common algorithms include Rijndael (AES) and Triple DES (3DES). These algorithms are designed to perform efficiently on common hardware architectures.

Symmetric cryptography is comparatively simple in nature, because the secret key that is used for both encryption and decryption is shared between the sender and the recipient. However, before communication can occur, the sender and the recipient must exchange a shared secret key. In some cases (such as SSL), asymmetric cryptography can be used to ensure that the initial key exchange occurs over a secure channel.


Key Management and Conventional Encryption
Conventional encryption has benefits. It is very fast. It is especially useful for encrypting data that is not going anywhere. However, conventional encryption alone as a means for transmitting secure data can be quite expensive simply due to the difficulty of secure key distribution. The expense of secure channels and key distribution relegated its use only to those who could afford it, such as governments and large banks (or small children with secret decoder rings).

Recall a character from your favorite spy movie: the person with a locked briefcase handcuffed to his or her wrist. What is in the briefcase, anyway? It's probably not the missile launch code/ biotoxin formula/ invasion plan itself. It's the key that will decrypt the secret data.

For a sender and recipient to communicate securely using conventional encryption, they must agree upon a key and keep it secret between themselves. If they are in different physical locations, they must trust a courier, the Bat Phone, or some other secure communication medium to prevent the disclosure of the secret key during transmission. Anyone who overhears or intercepts the key in transit can later read, modify, and forge all information encrypted or authenticated with that key. The persistent problem with conventional encryption is key distribution: how do you get the key to the recipient without someone intercepting it?

And the minor problem with it is the storage of keys: when you want to communicate with a lot of people and you have one key for each partner, how do you manage so many keys?




Some Examples of Conventional Cryptosystems

Captain Midnight's Secret Decoder Ring (which you may have owned when you were a kid)

Julius Caesar's cipher

DES, Data Encryption Standard