Question: Question 9 Select all the options which correctly call the following method: private static decimal CalculateSum(decimal[] salariesArray) { decimal salarySum = 0; for (int i

Question 9

Select all the options which correctly call the following method:

private static decimal CalculateSum(decimal[] salariesArray)

{

decimal salarySum = 0;

for (int i = 0; i < salariesArray.Length; i++) ;

{

salarySum = salarySum + salariesArray[i];

}

return salarySum;

}

Question 9 options:

A)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

double salarySum = CalculateSum(salaries);

B)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

decimal sumOfSalaries = CalculateSum(salaries);

C)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

decimal sumOfSalaries = CalculateSum(salaries[]);

D)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

CalculateSum(salaries);

Question 10

Select all the options which correctly calculate the average of all the grades

Question 10 options:

A)

double[] grades = { 90.0, 95.0, 97.0, 93.0, 80.0, 85.0, 75.0 };

double sum=0;

for (int i=0, i < grades.Length, i++)

{

sum += grades[i];

}

Console.WriteLine("Average is " + (sum / grades.Length));

B)

double[] grades = { 90.0, 95.0, 97.0, 93.0, 80.0, 85.0, 75.0 };

double sum=0;

for (int i=0; i < grades.Length; i++)

{

sum += grades[i];

}

Console.WriteLine("Average is " + (sum / grades.Length));

C)

double[] grades = { 90.0, 95.0, 97.0, 93.0, 80.0, 85.0, 75.0 };

double sum=0;

for (int i=0; i < grades.Length; i++)

{

sum = sum + grades[i];

}

Console.WriteLine("Average is " + (sum / grades.Length));

D)

double[] grades = { 90.0, 95.0, 97.0, 93.0, 80.0, 85.0, 75.0 };

double sum=0;

for (int i=0; i > grades.Length; i++)

{

sum += grades[i];

}

Console.WriteLine("Average is " + (sum / grades.Length));

Question 11

If an application needs to save a whole number value in a variable, what data type should the variable be? Select the best answer.

Question 11 options:

a)double

b)int

c)string

d)decimal

Question 12

What's wrong with the following code snippet?

string userEntry = Console.ReadLine();

string answer = Convert.ToString(userEntry);

if (String.Compare(answer,"Yes",true) == 0)

{

Console.WriteLine("User said yes");

}

Question 12 options:

a)There is a missing semi colon on this line  if (answer.Equals("Yes"));
b)Instead of this string userEntry = Console.ReadLine(); string answer = Convert.ToString(userEntry); c)the code should do this string answer = Convert.ToString(Console.ReadLine());
c)Instead of this   if (answer.Equals("Yes")) the code should do this if (answer.CompareTo("Yes") > 0)
d)

Instead of this

string userEntry = Console.ReadLine();

string answer = Convert.ToString(userEntry);

the code should do this

string answer = Console.ReadLine();

because converting a string to a string is unnecessary

Question 15

Select all the options that correctly define and initialize an array to a set of grades.

Question 15 options:

A)

double[] gradeValues = { 90.0, 80.0, 95.0, 85.0, 75.0, 70.0, 89.0, 97.0, 93.0, 63.0 };

B)

double gradeValues = [90.0, 80.0, 95.0, 85.0, 75.0, 70.0, 89.0, 97.0, 93.0, 63.0];

C)

double gradeValues = new { 90.0, 80.0, 95.0, 85.0, 75.0, 70.0, 89.0, 97.0, 93.0, 63.0 };

D)

double[] grade Values = { 90.0, 80.0, 95.0, 85.0, 75.0, 70.0, 89.0, 97.0, 93.0, 63.0 };

Question 16

Select all the options which correctly call the following method:

private static decimal CalculateSum(decimal[] salariesArray)

{

decimal salarySum = 0;

for (int i = 0; i < salariesArray.Length; i++)

{

salarySum = salarySum + salariesArray[i];

}

return salarySum;

}

Question 16 options:

A)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

decimal sumOfSalaries = CalculateSum(salaries[]);

B)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

decimal sumOfSalaries = CalculateSum(salaries);

C)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

CalculateSum(salaries);

D)

decimal[] salaries = { 90000.0m, 95000.0m, 97000.0m, 93000.0m, 80000.0m, 85000.0m, 705000.0m };

decimal salarySum;

CalculateSum(salaries) = salarySum;

Question 17

Which of the following code segments correctly reads in the user's age?

Question 17 options:

A)

string userEnteredAge = Console.Read();

int age = Convert.ToDouble(userEnteredAge);

B)

string userEnteredAge = Console.ReadLine();

double age - Convert.ToInt32(userEnteredAge);

C)

string userAgeString= Console.ReadLine();

int age = Convert.ToInt32( userAgeString );

D)

int age = Console.ReadLine();

Question 19

Select the correct code to place the variable value ( decimal currentSalary ) into the following list

List salariesList = new List();

Question 19 options:

a)salariesList[1] = currentSalary;

b)salariesList.Add(currentSalary);

c)salariesList[0] = currentSalary;

d)salariesList[i] = currentSalary;

Question 20

Examine this snippet of code. List salariesList = new List(); Select a code snippet below which correctly displays the first salary in the list.  

Question 20 options:

a)Console.WriteLine($"The first salary in the list is {salariesList[i]}");

b)Console.WriteLine($"The first salary in the list is {salariesList[1]}");

c)Console.WriteLine($"The first salary in the list is {salariesList[0]}");

d)Console.WriteLine($"The first salary is {salariesList.First}"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!