Tema nr. 2 Observa Observație! Scrieți rezolvarea rezolvarea direct în acest document! document!
1. Write Write an anonymous anonymous block block that uses a country country name name as input and prints prints the highest highest and lowest lowest elevations for that country. Use the wfcountries table. "ecute your block three times using United States of #merica$ %rench &epublic$ and 'apan. ()*#& vlowestelevation vlowestelevation number+,- S#U vlowestelevation vlowestelevation wfcountries.lowestelevation wfcountries.lowestelevation /type vhighestelevation vhighestelevation wfcountries.highestelevation wfcountries.highestelevation /type 023 S*)4 lowestelevation$ highestelevation 2345 vlowestelevation$ vhighestelev vhighestelevation ation %&56 wfcountries W7& countryname 8 9'apan: (06S5U4;U4.;U4*23 (06S5U4;U4.;U4*23+9the +9the lowest elevation is : << vlowestelevations- vlowestelevations- (06S5U4;U4.;U4*23 (06S5U4;U4.;U4*23+9the +9the highest elevation is : << vhighestelevations- vhighestelevations- 3( =. valuate the variables in the following code. #nswer the following >uestions about each variable. 2s it named well? Why or why not? 2f it is not named well$ what would be a better name and why? ()*#& countryname countryna me @#&)7#&= +,A- medianage 3U60&+B$=- 023 S*)4 countryname$ medianage 2345 countryname$ medianage %&56 wfcountries W7& countryname 8 CUnited States of #mericaC (06S5U4;U4.;U4*23 (06S5U4;U4.;U4*23+C +C 4he median age in C<uestion =. )hange the declarations so that they use the /4I;
attribute. ()*#& vcountryname wfcountries.countryname/4I; vmedianage wfcountries.medianage/4I; 023 S*)4 countryname$ medianage 2345 vcountryname$ vmedianage %&56 wfcountries W7& countryname 8 CUnited States of #mericaC (06S5U4;U4.;U4*23+C 4he median age in C<uestions. ()*#& " @#&)7#&=+=A- 023 "K8 C1=HC O CJ,BC (06S5U4;U4.;U4*23+"- 3(
#. What do you think the output will be when you run the above code? 3U60& DDD initial este char dar se face conversia implicita la number 0. 3ow$ run the code. What is the output? ,PQ ). 2n your own words$ describe what happened when you ran the code. (id any implicit conversions take place? )onversie implicita din char in number$ noutate in plLs>l B. Write an anonymous ;*LSM* block that assigns the programmer:s full name to a variable$ and then displays the number of characters in the name. ()*#& " @#&)7#&=+=A- 023 "K8 C;avel 6ariu 2ulianC (06S5U4;U4.;U4*23+*347+"-- 3( P. Write an anonymous ;*LSM* block that uses todayCs date and outputs it in the format of 96onth dd$ yyyy:. Store the date in a (#4 variable called mydate. )reate another variable of the (#4 type called vlastday. #ssign the last day of this month to vlastday. (isplay the value of vlastday. ()*#& 6I(#4 (#4K8SIS(#4 vlastday (#4K8*#S4(#I+6I(#4- 023 (06S5U4;U4.putline +45)7#& +6I(#4$ C6onth (( IIII C-<uestion H to add J, days to today:s date and then calculate and display the number of months between the two dates. ()*#& 6I(#4 (#4K8SIS(#4 6I(#4= (#4K86I(#4 O J, 023 (06S5U4;U4.putline +45)7#&+65347S04W3+6I(#4=$6I(#4--- (06S5U4;U4.putline +6I(#4<
weight K8 weight O 1 newlocn K8 CWestern C << newlocn DD ;osition 1 DD 3( weight K8 weight O 1 message K8 message << C is in stockC DD ;osition = DD 3( #. 4he value of weight at position 1 isK = 0. 4he value of newlocn at position 1 isK Western urope ). 4he value of weight at position = isKBA1 (. 4he value of message at position = isK ;roduct 1AA1= is in stock . 4he value of newlocn at position = isK eroare$ nu este declarant in blocul respectiv ()*#& weight 3U60&+H- K8 BAA message @#&)7#&=+=,,- K8 C;roduct 1AA1=C 023 ()*#& weight 3U60&+H- K8 1 message @#&)7#&=+=,,- K8 C;roduct 11AA1C newlocn @#&)7#&=+,A- K8 CuropeC 023 weight K8 weight O 1 newlocn K8 CWestern C << newlocn (06S5U4;U4.putline +C#. 4he value of weight at position 1 isK C << weight- (06S5U4;U4.putline +C0. 4he value of newlocn at position 1 isK C << newlocn - DD ;osition 1 DD 3( weight K8 weight O 1 message K8 message << C is in stockC (06S5U4;U4.putline +C). 4he value of weight at position = isK C << weight- (06S5U4;U4.putline +C(. 4he value of message at position = isK C << message- DD ;osition = DD 3( 1A. nter and run the following ;*LSM* block$ which contains a nested block. *ook at the output and answer the >uestions. ()*#& vemployeeid employees.employeeid/4I; vob employees.obid/4I; 023 S*)4 employeeid$ obid 2345 vemployeeid$ vob %&56 employees W7& employeeid 8 1AA ()*#& vemployeeid employees.employeeid/4I; vob employees.obid/4I;
023 S*)4 employeeid$ obid 2345 vemployeeid$ vob %&56 employees W7& employeeid 8 1AH (06S5U4;U4.;U4*23+vemployeeid<< C is a C<
1=. 6odify the block in >uestion H to omit the e"ception handler$ then reDrun the block. "plain the output. ()*#& vnumber 3U60&+J- 023 vnumber K8 QQQQ );4253 W73 547&S 473 (06S5U4;U4.;U4*23+C#n e"ception has occurredC << vnumber- 3( 1H. nter and run the following code and e"plain the output. ()*#& vnumber 3U60&+J- 023 vnumber K8 1=HJ ()*#& vnumber 3U60&+J- 023 vnumber K8 ,BPR vnumber K8 C# character stringC 3( );4253 W73 547&S 473 (06S5U4;U4.;U4*23+C#n e"ception has occurredC- (06S5U4;U4.;U4*23+C4he number isK C<