Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Document preview thumbnail
Preview 2 out of 61 pages
Exam (elaborations)

EGR 1400 (Introduction to Programming for Engineers) EXAM 1 QUESTIONS AND CORRECT DETAILED ANSWERS WITH WELL DETAILED RATIONALES/NEWEST UPDATE!!!

Document preview thumbnail
Preview 2 out of 61 pages

EGR 1400 (Introduction to Programming for Engineers) EXAM 1 QUESTIONS AND CORRECT DETAILED ANSWERS WITH WELL DETAILED RATIONALES/NEWEST UPDATE!!!

Content preview

EGR 1400 (Introduction to Programming for Engineers) EXAM 1 QUESTIONS
AND CORRECT DETAILED ANSWERS WITH WELL DETAILED RATIONALES/NEWEST
UPDATE!!!

Question 1
In C#, you can simulate rolling two dice by selecting a random number between 1 and 6 to
represent each die roll and then adding them together to get the dice total. If you roll the pair of
dice 50 times and record the results, can you achieve the same experimental results by simply
selecting one random number between 2 and 12 for each roll?
A) Yes, if the Visual C# code is written to scale the single random number between 2 and 12
B) Yes, using the same scaling as before
C) No, because the probability distribution is different; rolling two dice favors middle numbers
like 7, while a single random range is uniform
D) Yes, if the random number is selected using myRand.Next(2, 13)
E) None of the above
Correct Answer: C) No, because the probability distribution is different; rolling two dice
favors middle numbers like 7, while a single random range is uniform
Rationale: When rolling two six-sided dice, the sum of 7 is much more likely than a sum of 2
because there are more combinations that result in 7 (1+6, 2+5, 3+4, etc.). If you simply
pick a random number between 2 and 12, every number has an equal (uniform) chance of
appearing. Therefore, the experimental results would not reflect the true nature of dice
physics.

Question 2
What property of a Label control would you need to set to change the words displayed in the
Label on the form?
A) The Name property
B) The Captain property
C) The Word property
D) The Text property
E) The Display property
Correct Answer: D) The Text property
Rationale: In Windows Forms, the 'Name' property is used by the programmer to identify
the control in code (e.g., lblHeader), while the 'Text' property determines what the user
actually sees on the screen.

Question 3
Which of the following is the best name for a text box that will hold a person's age within a
Visual Studio .NET project, keeping in mind the recommended naming conventions?
A) Form1
B) txtAge
C) txtText1
D) Age

, 2



E) intAge
Correct Answer: B) txtAge
Rationale: Standard C# naming conventions for GUI controls suggest using a three-letter
prefix to identify the control type (txt for TextBox) followed by a descriptive name in
PascalCase. This makes code much more readable and easier to debug.

Question 4
When the user clicks a button in a C# Windows Forms application, ________ is raised.
A) A setting
B) A method
C) A property
D) An event
E) A class
Correct Answer: D) An event
Rationale: C# is an event-driven programming language. Actions performed by the user,
such as clicking a button, hovering a mouse, or pressing a key, trigger 'events' which then
execute specific blocks of code called event handlers.

Question 5
Which of the following statements will set the variable RandNum to a value between 1 and 3,
inclusive?
A) RandNum = myRand.Next(1, 3);
B) RandNum = myRand.Next(0, 3);
C) RandNum = myRand.Next(1, 4);
D) RandNum = myRand.Next(0, 4);
E) RandNum = myRand.Next(1, 5);
Correct Answer: C) RandNum = myRand.Next(1, 4);
Rationale: The Next(min, max) method in the C# Random class is inclusive of the lower
bound but exclusive of the upper bound. Therefore, to get a 3, the upper bound must be 4.
Question 6
What is the value of the following expression: float.Parse("3.8").ToString("0.00")?
A) 3.8
B) 3.80
C) 4
D) 03.80
E) 3.800
Correct Answer: B) 3.80
Rationale: float.Parse("3.8") converts the string to a numeric float value. The
.ToString("0.00") method then formats that number back into a string with exactly two
decimal places, regardless of whether they are zero.

Document information

Uploaded on
September 19, 2025
File latest updated on
February 25, 2026
Number of pages
61
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$17.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
Testmister
5.0
(516)
Sold
2706
Followers
2
Items
1183
Last sold
1 day ago


Reviews from verified buyers




Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions