Question
1. If you follow the recommendations from this week, which of the following is true? (Choose two) a. Your program will always work b. Your
1. If you follow the recommendations from this week, which of the following is true? (Choose two)
a. Your program will always work
b. Your program will be easier to read
c. Your programs will always be perfect
d. Other programmers will be more likely to work with you
2. Fix four flaws in the following program.
// Fix four flaws // Note: there are more than four flaws!
static void Main(string[] args) { string userName = Console.ReadLine(); DoLotsOfstuff(userName); }
static void DoLotsOfstuff(string n) { bool guest; int i;
if (n = "Student") { Console.WriteLine("Welcome " + n); guest = false; } else if (n = "Admin") { Console.WriteLine("Welcome " + n); guest = false; } else { Console.WriteLine("Welcome " + n); guest = true; }
for (i = 0; i < len(n); i++) Console.Write(n[i]); Console.WriteLine(); }
You will need to retype this program into C#, and then make changes. For ease of grading, please mark your changes with comments, such as:
// Change 2: Changed the variable name from n
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started