pmc 502 # lab
TRANSCRIPT
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 1/19
ENTERPRISE ARCHITECTURE USING C#.NET
(Lab Manual – MCA Vth / M.Sc.IT IIIrd S!"tr
C$d% PMC&')/PMI&*)
N$t%
+. I!,l!nt th -$ll$n0 1rc"" n C#
). Prnt th "crn $ut ,ut a" an $ut,ut
*. Write the algorithm of each program
2. Test the program with various cases
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 2/19
NAME OF DEPARTMENT: S!OO" OF OMP#T$N% &MA'
() Su*+ect Name: E,terprise Architecture usi,g -)NET
Su*+ect o.e: PM/012PM$30(1) C$ntact H$ur"% 2 L% T% P% 2
3) E1a!nat$n 3urat$n(Hr"% Th$r4 Practcal
4) Rlat5 60hta0% C6E MTE ETE/) Crdt"%
5) Semester:Autum, Spri,g 6oth
7) Pre8Re9uisite: O*+ect orie,te. programmi,g fu,.ame,tals)) Su*+ect Area: omputer Scie,ce;) 7b8ct5% The purpose of the first four exercises is to get used to the C# compiler and to get experience
with properties, operator overloading and user-defined conversions. Next four exercises include windows
application development using Microsoft .NET with C#. Next set of exercises represent web based
application development including !".NET and eb $orms.
(0) Details of the ourse:
Sl)NO ONTENT ONTAT!O#RS
( Write a Program in C# to Check whether a number isPalindrome or not.
10<1 = 40
1
Write a Program in C# to demonstrate Command line
arguments Processing.
3
Write a Program in C# to fnd the roots o Quadratic
Equation.
4
Write a Program in C# to Check whether a number is
Palindrome or not./ Write a Program in C# to demonstrate Command line
arguments processing5
Write a Program in C# to fnd the roots o Quadratic
Equation.
7
Write a Program in C# to demonstrate boing and
un!oing.
"
Write a Program in C# to implement tack
operations.
$
Write a program to demonstrate %perator
o&erloading.
'
( (
)(
)(* ) ,
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 3/19
*(
Write a Program in C# to fnd the second largest
element in a single dimensional arra-.
**
Write a Program in C# to multipl- to matrices using
ectangular arra-s.
*)/ind the sum o all the elements present in a 0agged
arra- o 1 inner arra-s.
*1
Write a program to re&erse a gi&en string using C#.
*,
2sing 3r-4 Catch and /inall- blocks write a program in
C# to demonstrate error handling.
*+
5esign a simple calculator using witch tatement in
C#.
*6
5emonstrate 2se o irtual and o&erride ke- words in
C# with a simple program
*7 Write a program to displa- the ollowing eedback orm. 3he di8erent options or the list bo must be 9P:;<=4 5ot>E34 ?a&aPro and 2ni4C4C@@. When the ubmit /orm button is clickedater entering the data4 a message as seen in the last line o theabo&e fgure must be displa-ed.
*"
Write a program that displa-s a button in green color and it
should change into -ellow when the mouse mo&es o&er it.*$ Write a program containing the ollowing controlsA
B 9 =ist!oB 9 !uttonB 9n mageB 9 =abel
3he listbo is used to list items a&ailable in a store.When the user clicks on an item in the listbo4 itsimage is displa-ed in the image control. When theuser clicks the button4 the cost o the selected item isdispla-ed in the control.
)( Write a ?a&acript code that displa-s two ad&ertisementsalternatel-. When the user clicks on one o thead&ertisements4 heDshe is redirected towww.amaFon.comG4 and the other ad&ertisement redirectsthe user to www.abmart.comG. 3he weightage o theamaFon ad&ertisement is +( and that o the other one is,(. 3he ad&ertisement should be centered horiFontall- andshould co&er 6(H o the width o the screen. ts heightshould be "( units. 3he width o the border should be +
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 4/19
units.
TOTA" 40
(() Suggeste. 6oo>s:
Sl)NO NAME OF A#T!ERS26OO?S2P#6"$S!ERS @EAR OFP#6"$AT$ON2REPR$
NT
*. C# Programming =anguage ICo&ering C# ,.(J4 3he I,th EditionJ I<icrosot.>E3 5e&elopment eriesJ 9uthorA 9nders Ke0lsberg4 <ads 3orgersen4 cottWiltamuth4 and Peter Lolde
). Kead /irst C#4 )EA 9 =earnerMs Luide to eal:World Programming withisual C# and .>E3 IKead /irst LuidesJ b- 9ndrew tellman and ?ennierLreene
1. C# ,.( in a >utshellA 3he 5efniti&e eerence b- ?oseph 9lbahari and !en9lbahari
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 5/19
*. Write a Program in C# to Check whether a number is Palindrome or not.using -stemclass palindrome
Bpublic static &oid <ainCB
int num N ( re& num* N ( num) N (Console.Write=ineCOEnter a numberO
num N int.ParseCConsole.ead=ineCnum) N numwhile Cnum (B
re& N num H *(num N num D *(num* N num* *( @ re&
i Cnum* NN num)
Console.Write=ineCO>umber is PalindromeOelse
Console.Write=ineCO>umber is >%3 PalindromeO Console.eadC
). Write a Program in C# to demonstrate Command line arguments Processing.using -stemclass cmdarg B
public static &oid <ainCB
int num N (tring&' argument N En&ironment.LetCommand=ine9rgsCor Cint i N * i R argument.=ength i@@
num N num @ int.ParseCargument&i'Console.Write=ineCOum is O @ num
Console.eadC
1. Write a Program in C# to fnd the roots o Quadratic Equation.using -stempublic class roots B
double a N ( b N ( c N ( d N ( r* N ( r) N ( n N ( m N (public &oid inputCB
Console.Write=ineCOEnter the quardatic EquationOa N double.ParseCConsole.ead=ineCb N double.ParseCConsole.ead=ineCc N double.ParseCConsole.ead=ineCd N <ath.qrtCb b : , a ci Cd NN (B
Console.Write=ineCO3he oots or the gi&en Equation are eal and EqualOr* N r) N :b D C) aConsole.Write=ineCOoot isA O @ r* @ OandO @ r)
else i Cd R (B
Console.Write=ineCOoots or te gi&en equation are eal and distinctO r* N C:b @ d D C) a r) N C:b : d D C) aConsole.Write=ineCO3he oots areA O @ Cintr* @ OandO @ Cintr)
else B
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 6/19
Console.Write=ineCO3he oots or the gi&en Equation are maginar-On N :b D C) am N <ath.qrtC<ath.9bsCb b : , a c D C) aConsole.Write=ineCOoot *A O @ n @ O@i O @ mConsole.Write=ineCOoot )A O @ n @ O:i O @ m
class Quad B
public static &oid <ainCB
roots r N new rootsCr.inputC
Console.eadC
,. Write a Program in C# to Check whether a number is Palindrome or not.
using -stemclass Pallin
B public static &oid <ainCtring&' args B int dnre&m Console.Write=ineCOEnter the numberO nNint.ParseCConsole.ead=ineC mNn re&N( whileCnSN( B dNnH*( re&Nre&*(@d nNnD*( i Cre&NNm
B Console.Write=ineCOEntered number O@m@O is pallindromeO else B Console.Write=ineCOEntered number O@m@O is not pallindromeO
+. Write a Program in C# to demonstrate Command line arguments processing.
using -stemTnamespace Console9pplication*Uclass CommandlineUstatic &oid <ainIstringV argsJUConsole.WriteIWE=C%<E to JTConsole.WriteIG G @ argsV(JTConsole.WriteIG G @ argsV*JTConsole.ead=ineIJTXXX
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 7/19
DDanotherusing -stemTclass Command=ine9rgs Upublic static &oid <ainItringV argsJ Udouble a4bTiIargs.=engthNN(J UConsole.Write=ineI>o arguments oundGJTXelse UaNdouble.ParseIargsV(JTbNdouble.ParseIargsV*JTdouble sumN(4mulN(4di&N(4subN([email protected]=ineIum o @a@G and @b@G is @sumJTsubNa:bTConsole.Write=ineIG ubstraction o @b@G b- @a@G is @subJTmulNabTConsole.Write=ineIG <ultiplication o @a@G and @b@G is @mulJTdi&NaDbTConsole.Write=ineIG 5i&ision o @a@G b- @b@G is @di&JTXXX
6. Write a Program in C# to fnd the roots o Quadratic Equation.
using -stemTusing -stem.3etTnamespace Console9pplication*Uclass QuadY U static &oid <ainIstringV argsJU int a4 b4 cTZoat d4 *4 )TConsole.Write=ineI[n Enter a4b4c A[nGJTConsole.WriteIG a N JTa N Con&ert.3ont1)IConsole.ead=ineIJJTConsole.WriteIG b N JTb N Con&ert.3ont1)IConsole.ead=ineIJJTConsole.WriteIG c N JTc N Con&ert.3ont1)IConsole.ead=ineIJJTd N b b \ , a cT
i Id (JU Console.Write=ineI[n Equation has two roots.GJT* N IZoatJI:b @ <ath.qrtIdJJ D I) aJT) N IZoatJI:b \ <ath.qrtIdJJ D I) aJTConsole.Write=ineI[n 3he roots areA[nGJTConsole.Write=ineI[n root* N @*@G[n root) N @)JTXelse i Id NN (JUConsole.Write=ineI[n Equation has onl- one root.GJT* N IZoatJ:b D I) aJTConsole.Write=ineI[n 3he root isA[nGJTConsole.Write=ineI[n root N G @ *JTXelseU
Console.Write=ineI[n Equation has imaginar- roots.GJT* N IZoatJ:b D I) aJT) N IZoatJ<ath.qrtI:dJ D I) aJTConsole.Write=ineI[n 3he roots areA[nGJTConsole.Write=ineI[n root* N G @ * @ G @ G @ ) @ G i [nG @ G root) N G @ * @ G \ G @ ) @ G iJTXConsole.ead=ineIJTX X X
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 8/19
7. Write a Program in C# to demonstrate boing and un!oing.
using -stemTclass !o2nbo Upublic static &oid <ainIJUint numTConsole.WriteIEnter the number A JTnumNint.ParseIConsole.ead=ineIJJT
%b0ect oNnumTConsole.Write=ineIalue in numN @numJTConsole.Write=ineIalue in %b0ect (NG@oJTint nTnNIintJoTConsole.Write=ineIalue o nNG@nJTXX
". Write a Program in C# to implement tack operations.
using -stemTclass tackUpublic static &oid <ainItringV argsJ
Uint topN:*4num4choice4ma4rptN*TintV stackNnew intV)(TConsole.Write=ineIEnter the maimum limitGJTmaNint.ParseIConsole.ead=ineIJJTwhileIrptSN(JUConsole.Write=ineItack %perationGJTConsole.Write=ineI* . P2KGJTConsole.Write=ineI) . P%PGJTConsole.Write=ineI1 . 5P=9]GJTConsole.Write=ineI( . E;3GJTConsole.Write=ineIEnter -our choiceAGJTchoiceNint.ParseIConsole.ead=ineIJJTswitchIchoiceJU
case *AiItopNNIma:*JJ UConsole.Write=ineItack is ullGJTXelse UConsole.Write=ineIEnter the element to be insertedAGJTnumNint.ParseIConsole.ead=ineIJJTstackV@@topNnumTConsole.Write=ineIElement is successull- insertedGJTXbreakTcase )AiItopNN:*JUConsole.Write=ineItack is Empt-GJTXelse UConsole.Write=ineI5eleted Element is AG@stackVtop::JTXbreakTcase 1AiItopNN:*JUConsole.Write=ineItack is Empt-GJTXelse U
Console.Write=ineIElements in the stackGJTorIint iNtopTiN(Ti\J
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 9/19
UConsole.Write=ineIstackViJTXXbreakTcase (AEn&ironment.EitI(JTbreakTdeaultAConsole.Write=ineIWorng Enter-GJTbreakTXXXX
$. Write a program to demonstrate %perator o&erloading.
using -stemT
public struct CompleUpublic int realTpublic int imaginar-T
public CompleIint real4 int imaginar-JUthis.real N realTthis.imaginar- N imaginar-TX
DD 5eclare which operator to o&erload I@J4 the t-pesDD that can be added Itwo Comple ob0ectsJ4 and theDD return t-pe ICompleJApublic static Comple operator @IComple c*4 Comple c)JUreturn new CompleIc*.real @ c).real4 c*.imaginar- @ c).imaginar-JTXDD %&erride the 3otring method to displa- an comple number in the suitable ormatApublic o&erride string 3otringIJ
UreturnItring./ormatIU(X @ U*XiG4 real4 imaginar-JJTX
public static &oid <ainIJUComple num* N new CompleI)41JTComple num) N new CompleI14,JT
DD 9dd two Comple ob0ects Inum* and num)J through theDD o&erloaded plus operatorAComple sum N num* @ num)T
DD Print the numbers and the sum using the o&erriden 3otring methodAConsole.Write=ineI/irst comple numberA U(XG4num*JT
Console.Write=ineIecond comple numberA U(XG4num)JTConsole.Write=ineI3he sum o the two numbersA U(XG4sumJT
XX
*(.Write a Program in C# to fnd the second largest element in a single dimensional arra-.
dimensional arra-.
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 10/19
using -stemTusing -stem.Collections.LenericTusing -stem.3etT
namespace secondlargestUclass ProgramUstatic &oid <ainIstringV argsJU
intV arr NU (4 +4 74 :)4 $4 *)4 ,4 " XTint high4 sechigh4tempThigh N sechigh N arrV(TConsole.Write=ineI9rra- elements areGJTor Iint i N (T i R arr.=engthT i@@JConsole.WriteIarrVi@G JTConsole.Write=ineIJTor Iint i N (T i R arr.=engthT i@@JUtemp N arrViTi Itemp highJUsechigh N highThigh N tempTXelse i Itemp sechigh ̂ ^ temp SN highJ
sechigh N tempTXConsole.Write=ineI3he second largest number in the arra- is G @ sechighJTConsole.ead=ineIJTXXX
**.Write a Program in C# to multipl- to matrices using ectangular arra-s.
using -stemTclass matrimulUpublic static &oid <ainItringV argsJ
UintV4 aNnew int V+4+TintV4 bNnew int V+4+TintV4 cNnew int V*(4*(Tint m4n4i404p4q4kTConsole.Write=ineIEnter the order o frst matriGJTmNint.ParseIConsole.ead=ineIJJTnNint.ParseIConsole.ead=ineIJJTConsole.Write=ineIEnter the order o second matriGJTpNint.ParseIConsole.ead=ineIJJTqNint.ParseIConsole.ead=ineIJJTiInSNpJConsole.Write=ineInot possibleGJTelseUConsole.Write=ineIenter arra- elements o forst matri JT
orIiN(TiRmTi@@JorI0N(T0RnT0@@JaVi40Nint.ParseIConsole.ead=ineIJJT
Console.Write=ineIenter arra- elements o second matri JTorIiN(TiRpTi@@JorI0N(T0RqT0@@JbVi40Nint.ParseIConsole.ead=ineIJJT
orIiN(TiRmTi@@JUorI0N(T0RqT0@@J
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 11/19
UcVi40N(TorIkN(TkRnTk@@[email protected]=ineI[tesult o <ultiplicationGJTorIiN(TiRmTi@@JUorI0N(T0RqT0@@JConsole.WriteI[[email protected]=ineIJTXXXX
*)./ind the sum o all the elements present in a 0agged arra- o 1 inner arra-s.
using -stemTclass <-0agged9rrUpublic static &oid <ainIJU
intVV m-0agNnew intV1VT
orIint iN(TiRm-0ag.=engthTi@@JUm-0agViNnew intVi@1TX
orIint iN(TiR1Ti@@JUConsole.Write=ineIEnter the Elements o rowU(XG4iJT
orIint 0N(T0Rm-0agVi.=engthT0@@JU
m-0agViV0Nint.ParseIConsole.ead=ineIJJTXXint sumN(TorIint iN(TiR1Ti@@JUorIint 0N(T0Rm-0agVi.=engthT0@@[email protected]=ineIsumNG@sumJTXX
*1.Write a program to re&erse a gi&en string using C#.
using -stemTusing -stem.3etT
namespace Console9pplication*Uclass e&erseY Ustatic &oid <ainIstringV argsJUtring in&T
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 12/19
tring out&NGOTConsole.Write=ineIG Enter a string A[nGJTin&NConsole.ead=ineIJTorIint iNin&.=ength:*TiN(Ti\JUout&Nout&@in&.ubstringIi4*JTXConsole.Write=ineI3he re&ersed string isA @out&JTConsole.ead=ineIJTXXX
*,.2sing 3r-4 Catch and /inall- blocks write a program in C# to demonstrate
error handling.
using -stemTusing -stem.Collections.LenericTusing -stem.=inqTusing -stem.3etTnamespace Console9pplication*Uclass EceptionUstatic int m N *(T
static int n N (Tstatic &oid 5i&isionIJUtr-Uint k N m D nTXcatch I9rgumentEception eJUConsole.Write=ineIEception caughtAG @ e.<essageJTXfnall-UConsole.Write=ineInside di&ision methodGJTConsole.ead=ineIJTX
Xstatic &oid <ainIstringV argsJUtr-U5i&isionIJTXcatch I5i&ide!-_eroEception eJUConsole.Write=ineIEception caughtAG @ e.<essageJTXfnall-UConsole.Write=ineIinside main methodGJTConsole.ead=ineIJTXXX X
*+.5esign a simple calculator using witch tatement in C#.
using -stemTclass imcalc Upublic static &oid <ainItringV argsJUdouble a4b4rptN*T
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 13/19
int choiceTwhileIrptSN(JUConsole.Write=ineIelect the operationGJTConsole.Write=ineI* . 9dditionGJTConsole.Write=ineI) . ubtractionGJTConsole.Write=ineI1 . <ultiplicationGJTConsole.Write=ineI, . 5i&isionGJTConsole.Write=ineI( . EitGJTConsole.Write=ineIEnter ur choice AGJTchoiceNint.ParseIConsole.ead=ineIJJTswitchIchoiceJUcase *AConsole.Write=ineIEnter two numbersAGJTaNdouble.ParseIConsole.ead=ineIJJTbNdouble.ParseIConsole.ead=ineIJJTConsole.Write=ineIesult o 9ddition A @Ia@bJJTbreakTcase )AConsole.Write=ineIEnter two numbersAGJTaNdouble.ParseIConsole.ead=ineIJJTbNdouble.ParseIConsole.ead=ineIJJTConsole.Write=ineIesult o ubtraction A @Ia:bJJTbreakTcase 1AConsole.Write=ineIEnter two numbersAGJT
aNdouble.ParseIConsole.ead=ineIJJTbNdouble.ParseIConsole.ead=ineIJJTConsole.Write=ineIesult o <ultiplication A @IabJJTbreakTcase ,AConsole.Write=ineIEnter two numbersAGJTaNdouble.ParseIConsole.ead=ineIJJTbNdouble.ParseIConsole.ead=ineIJJTiIbNN(J UConsole.Write=ineI5i&ision not possibleGJTXelse UConsole.Write=ineIesult o 5i&ision A @IaDbJJTXbreakTcase (A
rptN(TbreakTdeaultAConsole.Write=ineIn&alid selectionGJTbreakTXXXX
*6.5emonstrate 2se o irtual and o&erride ke- words in C# with a simple program
using -stemTusing -stem.Collections.LenericTnamespace Console9pplication*
Upublic class CustomerUpublic &irtual &oid Customer3-peIJUConsole.Write=ineI am customerGJTXXpublic class CorporateCustomerACustomerUpublic o&erride &oid Customer3-peIJUConsole.Write=ineI am Corporate CustomerGJT
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 14/19
XXpublic class PersonalCustomerACustomerUpublic o&erride &oid Customer3-peIJUConsole.Write=ineI am personal customerGJTXXclass ProgramUstatic &oid <ainIstringV argsJUCustomerV cNnew CustomerV1TcV(Nnew CorporateCustomerIJTcV*Nnew CorporateCustomerIJTcV)Nnew CustomerIJToreachICustomer customerob0ect in cJUcustomerob0ect.Customer3-peIJTXConsole.ead=ineIJTXXX
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 15/19
*7.
*". Write a program that displa-s a button in green color and it should change into -ellow whenthe mouse mo&es o&er it.
olution.
<html>
<head><title> ASP.NET </title>
</head>
<form id=f1 runat=”server”><body><font olor=”!reen”><s"an id=s1 runat=”server” /></font><br><br><h#> $ove The $ouse %ver $e and oy </h#><as"&button id=”'utton() %nServer*li+=”'utton(,*li+” te-t=”*li+ me toostyle=”font& 0"t
verdanaba+!round2olor&li!ht!reenborder2olor&bla+hei!ht=#34idth&133)onmouseover=”this.style.ba+!round*olor=5yello45”onmouseout=”this.style.ba+!round*olor=5li!ht!reen5”runat=”server”/></form></body></html>
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 16/19
*$.Write a program containing the ollowing controlsA
B 9 =ist!oB 9 !uttonB 9n mageB 9 =abel
3he listbo is used to list items a&ailable in a store. When the user clicks on an item inthe listbo4 itsimage is displa-ed in the image control. When the user clicks the button4 the cost othe selected item isdispla-ed in the control.
olutionA<html><head><Sri"t lan!ua!e=”6” runat=”Server”>void *alulate7%b8et sender9EventAr!s e:;if 7Store.Seletednde- > 21:;int i = Store.Seletednde-*ost.Te-t = ou have hosen Store.Seletedtem.?alue andits ost is @s.”
if 7i==3:*ost.Te-t = #3”else if 7i==1:*ost.Te-t = #(”else if 7i == (:*ost.Te-t = (0”else*ost.Te-t = (”BBvoid dis"lay7%b8et sender9 EventAr!s e:
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 17/19
;int i = Store.Seletednde-if 7i==3:;m!.ma!eCrl = *ola.!if”m!.AlternateTe-t = *ola”Belse if 7i==1:;m!.ma!eCrl = @ed,"o".!if”
m!.AlternateTe-t = @ed Po"”Belse if 7i == (:;m!.ma!eCrl = Dime.!if”m!.AlternateTe-t = Dime”Belse;m!.ma!eCrl = Pur"le,@ain.!if”m!.AlternateTe-t = Pur"le @ain”BB</Sri"t></head><body>
<form runat=”server”><as"&label id = label1” Te-t=”*hoose one of the items belo4”ont2Name=”?erdana” ont2SiFe=”10"t” runat=”server” /><br><br><as"&listbo- id=”Store” AutoPost'a+=”True” 4idth=”(33)runat=”server” onSeletednde-*han!ed=”dis"lay”><as"&listitem>*ola</as"&listitem><as"&listitem>@ed Po"</as"&listitem><as"&listitem>Dime</as"&listitem><as"&listitem>Pur"le @ain</as"&listitem></as"&listbo-><as"&ma!e G=”m!” ma!eCrl=”” AlternateTe-t=”” runat=”server” /><br><br><as"&button id=”ind” te-t=”ind *ost” %n*li+=”*alulate”runat=”server”/><br><br>
<as"&te-tbo- id=”*ost” te-t=”3) 4idth=#H3 runat=”server”/>
</form></body>
</html>
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 18/19
)(. Write a ?a&acript code that displa-s two ad&ertisements alternatel-. When the user clicks onone o the ad&ertisements4 heDshe is redirected to www.amaFon.comG4 and the other
ad&ertisement redirects the user to www.abmart.comG. 3he weightage o the amaFonad&ertisement is +( and that o the other one is ,(. 3he ad&ertisement should be centeredhoriFontall- and should co&er 6(H o the width o the screen. ts height should be "( units. 3hewidth o the border should be + units.
olution.
The ASPI file&<html><body><*enter><as"&Ad@otator Jidth = 3K” Lei!ht=03 id=a1Advertisementile=”ads.-ml” 'orderJidth=H runat=server /></*enter></body></html>
The I$D file&<Advertisements><Ad><ma!eCrl> amaFon.!if </ma!eCrl><Navi!ateCrl> htt"&//444.amaFon.om </Navi!ateCrl><AlternateTe-t> Jelome to AmaFon</AlternateTe-t><Mey4ord> 4ebsites </Mey4ord><m"ressions>H3</m"ressions></Ad><Ad><ma!eCrl> fabmart.!if </ma!eCrl><Navi!ateCrl> htt"&//444.fabmart.om </Navi!ateCrl>
7/23/2019 PMC 502 # Lab
http://slidepdf.com/reader/full/pmc-502-lab 19/19
<AlternateTe-t> Jelome to abmart </AlternateTe-t><Mey4ord> 4ebsites </Mey4ord>
<m"ressions>3</m"ressions></Ad>
</Advertisements>
ub0ect 3eacherA 9shish Yumar Pal5epartmentA Computer cience ^ EngineeringCourse ^ emA <C9 th emester