The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Write an explanation for the correct answers for items 1 - 3.
SCENARIO: Reina has created a simple DVR application to record her favorite television programs, but her code has some bugs. She’s a big sports fan and always wants to record the broadcasts of sporting events, even if they conflict with another of her favorite programs.
For non-sport favorites, she does not want to record reruns; however, if the scheduled time of a favorite program conflicts with another favorite and will be broadcast again later, she wants to wait and record it in the future.
Unfortunately, her program is not working correctly. Many television programs that she doesn’t want are being recorded; the programs she DOES want are only being recorded if they are broadcast later.
The C# code (with line numbers added) of Reina’s DVR program looks like this:
Â
Â
1:Â if (isSportsEvent) {
2: Â Â Â Â Â Â Â Â RecordShowNow();
3:Â }
4:Â else {
5: Â Â Â Â Â Â Â Â if (!isConflict || !isRerun) {
6: Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â RecordShowNow();
7:Â Â Â Â Â Â Â Â Â }
8:Â Â Â Â Â Â Â Â Â if (isConflict && isOnLater); {
9: Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â RecordShowLater();
10: Â Â Â Â Â Â Â }
11:Â }
Â
Â
1. Which line is causing shows to be recorded now even if there is a conflict?
a. line 4
b. line 5
c. line 8
Indentation used in
.
2. How should line 8 be rewritten?
a. if (isOnLater); {
b. if (isConflict || isOnLater); {
c. if (isConflict && isOnLater) {
Â
3. Reina has placed two control structures (lines 5–7 and lines 8–10) inside her first control
structure. This techniqueis known as:
a. parenting
b. encapsulating
c. nesting