Ads

Pages

Showing posts with label CS. Show all posts
Showing posts with label CS. Show all posts

Thursday, January 6, 2011

CS201 Assignment No. 3 solution

#include

#include
#include

class calsalary
{
private:
int empID,empGrade;
char empName[20];
int salary;
public:
calsalary()
{
empID=0;
empGrade=0;
strcpy(empName," ");
salary=0;
}
void getData()
{
cout<<"please enter employee ID:";
cin>>empID;
cout<<"Please enter employee Name:";
cin>>empName;
cout<<"Please enter employee Grade:";
cin>>empGrade;
}
int calculate(int grade)
{
switch(grade)
{
case 17:
salary=15000+(15000*45/100);
break;
case 18:
salary=20000+(20000*45/100);
break;
case 19:
salary=25000+(25000*45/100);
break;
default:
cout<< "Your typed Grade in not listed";
break;
}
return salary;
}
void setData()
{
cout<<"The net salary of" <
}

~calSalary()
{
}
};
int main(void)
{
calSalary obj1;
obj1.getData();
obj1.setData();

system("pause");
return 0;
}

.....................
#include
#include
#include
using namespace std;
class CalSalary
{private:
int EID, EGrade;
string Name;
public:
CalSalary()
{EID=0;
EGrade=0;
Name='/0';}
void GetInput()
{cout<<"please enter employee name : ";
cin>>Name;
cout<<"please enter employee ID : ";
cin>>EID;
cout<<"please enter employee Grade : ";
cin>>EGrade;}

int GetID()
{return EID;}
void SetID(int ID)
{EID=ID;}
int GetGrade()
{return EGrade;}
void SetGrade(int Grade)
{EID=Grade;}
string GetName()
{return Name;}
void SetName(string N)
{Name=N;}
void Calculate(int G)
{switch(G)

{case 17:
{cout<
break;}
case 18:
{cout<
break;}
case 19:
{cout<
break;}
default :
cout<<"Grade of Employee is incorrect"<

}
}

};
main()
{ int G=0;
CalSalary cal;
cal.GetInput();
G=cal.GetGrade();
cal.Calculate(G);
getch();
}

.............
#include
#include
#include
using namespace std;
class CalSalary
{private:
int EID, EGrade;
string Name;
public:
CalSalary()
{EID=0;
EGrade=0;
Name='/0';}
void GetInput()
{cout<<"please enter employee name : ";
cin>>Name;
cout<<"please enter employee ID : ";
cin>>EID;
cout<<"please enter employee Grade : ";
cin>>EGrade;}

int GetID()
{return EID;}
void SetID(int ID)
{EID=ID;}
int GetGrade()
{return EGrade;}
void SetGrade(int Grade)
{EID=Grade;}
string GetName()
{return Name;}
void SetName(string N)
{Name=N;}
void Calculate(int G)
{switch(G)

{case 17:
{cout<
break;}
case 18:
{cout<
break;}
case 19:
{cout<
break;}
default :
cout<<"Grade of Employee is incorrect"<

}
}

};
main()
{ int G=0;
CalSalary cal;
cal.GetInput();
G=cal.GetGrade();
cal.Calculate(G);
getch();
}

Tuesday, January 4, 2011

CS403 Database Management Systems Assignment#3 Solution


Second Normal Form

Student ID

Name

Vu001

Faizan

Vu001

Faizan

Vu002

Zafar

Vu003

Ahmad

Vu003

Ahmad

Vu003

Ahmad

Vu004

Fahad

Vu004

Fahad




Specialization semester

Semester start date

Semester end date

Fall 2009

05-07-09

31-12-09

Spring 2010

05-02-10

30-06-10

Spring 2010

05-02-10

30-06-10

Fall 2009

05-07-09

31-12-09

Spring 2010

05-02-10

30-06-10

Fall 2010

05-07-10

31-12-10

Fall 2010

05-07-10

31-12-10

Spring 2011

05-02-11

30-06-11

Specialization

Specialization supervisor

SE

Prof. Majid

AI

Prof. Saeed

AI

Prof. Saeed

SE

Prof. Majid

Networks

Prof. Wajid

AI

Prof. Saeed

SE

Prof. Majid

AI

Prof. Saeed

Third Normal Form

Specialization

Specialization semester

Semester start date

Semester end date

SE

Fall 2009

05-07-09

31-12-09

AI

Spring 2010

05-02-10

30-06-10

AI

Spring 2010

05-02-10

30-06-10

SE

Fall 2009

05-07-09

31-12-09

Networks

Spring 2010

05-02-10

30-06-10

AI

Fall 2010

05-07-10

31-12-10

SE

Fall 2010

05-07-10

31-12-10

AI

Spring 2011

05-02-11

30-06-11

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">

Saturday, November 27, 2010

CS 604 assignment no 2 solution









Wednesday, November 24, 2010

CS-504 Assignment#2 Solution

Q1:Differentiate the following

1) Coupling and Cohesion

2) Object-Oriented and Function-Oriented design

Your solution should be in following format:

Coupling

Cohesion

Coupling between modules/components is their degree of joint interdependence; lower coupling is healthier.

Cohesion of a solitary module/component is the degree to which its responsibilities form a significant unit; higher cohesion is healthier.

v Size: number of relations between routines

v intimacy: the directness of the link among routines

Someone had indistinct reference to decomposability here. Amplification?

v visibility: the prominence of the connection between routines

v flexibility: the ease of changing the connections between routines

How concerning: 'Cohesion is inversely relative to the number of responsibilities a module/part has.'

Coupling explains how dependent a given part of software is on other modules. An extremely coupled system in one in which the events in one module can directly right to use rudiments of another module. A low coupled system in one in which the events of one module can only interrelate with the procedures of another during an interface channel. Highly coupled systems are often characterized by code that is hard to read & maintain (the cause cohesion and coupling are frequently used as opposites).

Cohesion explains how "paying attention" a part of software is. A highly-cohesive system is one in which all procedures in a specified module work jointly towards some end aim. High cohesion is frequently typified by high readability and maintainability.

Object-Oriented Design

Function-Oriented Design

The Basic concept is not the services accessible to the clients of the system

The basic concept is available to clients of the system

The state information survive in the form of data distributed between several objects of the system

The state information is accessible in a federal shared data store.

Group function jointly on the basis of data they work on

Group Functions together if as a group, they constitute a higher level Function

Where OOP orients on objects,

Or as called in C++ classes.

Functional oriented plan familiarize on functions

Object is data with techniques of processing it.

Functions, obtain some data, process it and then revisit result, or do several actions.

Q2

1) Write down any custom built C++ Class which you think is not cohesive (or low cohesive).

Public I Enumerable GetEmployeesFromDb_LowCohesion()

{
// instantiate the links
using(SqlConnection connection = newSqlConnection(ConfigurationManager.ConnectionStrings[CONNECTION_STRING_KEY].ConnectionString))
using(SqlCommand command = new SqlCommand("spGetEmployee", connection)) // instantiate the command

{
command.CommandType = CommandType.StoredProcedure;

// try to open the links
try
{
connection.Open();
}
catch (InvalidOperationException ex)
{
// log exemption
throw;
}
catch (SqlException ex)
{
// log exemption
throw;
}
catch (Exception ex)
{
// log exception
throw;
}

// perform the reader & read the results
using(SqlDataReader reader = command.ExecuteReader())
{
Int32 m_NameOrdinal, m_DeptOrdinal;

// obtain the ordinals
try
{
m_NameOrdinal = reader.GetOrdinal(NAME);
m_DeptOrdinal = reader.GetOrdinal(DEPARTMENT);
}
catch(System.IndexOutOfRangeException ex)
{
// log exemption
throw;
}

Collection result = new Collection();

// interpret the results
while(reader.Read())
{
try
{
Employee emp = new Employee();
emp.Name = reader.IsDBNull(m_NameOrdinal) ? String.Empty: reader.GetString (m_NameOrdinal);
emp.Department = reader.IsDBNull (m_NameOrdinal) ? String.Empty : reader.GetString(m_DeptOrdinal);
result.Add(emp);
}
catch (IndexOutOfRangeException ex)
{
// Log the exemption
throw; // rethrow or handle gracefully here
}
catch (Exception ex)
{
// Log the universal exemption
throw; // rethrow or handle gracefully here
}
}

return result;
}
}
}