Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assignment 1 Please finish all short answers. 1. Question 1 The code you are che

ID: 3883244 • Letter: A

Question

Assignment 1

Please finish all short answers.

1. Question 1

The code you are checking is as follows:

Is there an error, if so what is it and what does it do? What type of error?

2. Question 2

You are checking some code to generate numbers to letter grades using letters only.

The code is as follows:

  if (GPA > 91 && GPA < 100)
            {grade = "A";}
   else if (GPA > 81 && GPA < 90)
            {grade = "B";}
   else if (GPA > 71 && GPA < 80)
            {grade = "C";}
       else if (GPA > 61 && GPA < 70)
              {grade = "D";}
  else
           {grade = "F";}

  Are there any errors, what type of error are they? What type of error?

3. Question 3

You are doing a code review on a Web application that uses a function:

function calculatevalue (x)
(
     v = x+y;
     return v;
}

The function is called in the code:

<button (x, y):”>Calculate</button>

Are there any mistakes in the code? Describe any problem that exists and classify the type of error.

Question 4

You are asked to do a code review on an application that displays prices after the price has been increased. There is to be a 10% increase and the code is listed as follows:

newPrice = CurrentPrice * 0.10;
display (“New ” + newPrice);

Is there an error?  Describe any problem that exists and classify the type of error.

Question 5

This example function in C to calculate the average of two numbers.

int average(int a, int b) {      return a + b / 2;      }

Is there an error?  Describe any problem that exists and classify the type of error.

static OSStatus SSLVerifySignedServerKeyExchange(SSLContext *ctx, bool isRsa, SSLBuffer signedParams, uint8_t *signature, UInt16 signatureLen) OSStatus err: if ((err = SSLHashSHA1.update(&h; as hCtx, goto fail; &serverRandom;)) != 0) ((err &sig; nedParams)) 0) SSLHashSHA1.update(&h; as hCtx, goto fail; goto fail; if != ((err &hashOut;)) 0) SSLHashSHA1.final(6hashCtx, goto fail; if != = fail: SSLFreeBuffer(&signedHashes;) SSLFreeBuffer &hashCtx;); return err:

Explanation / Answer

Question 1

Answer:

return type is missing for first block. If None of if conditions execute then fail block will not execute so in this case we have to return err in first block also.

return err; is missing in first block.

Question 2

Answer: <= and >= are missing. Highlighted the changes below.

if (GPA >= 91 && GPA <= 100)
            {grade = "A";}
   else if (GPA >= 81 && GPA <= 90)
            {grade = "B";}
   else if (GPA >= 71 && GPA <= 80)
            {grade = "C";}
       else if (GPA >= 61 && GPA <= 70)
              {grade = "D";}
  else
           {grade = "F";}

Question 3

Answer: Second parameter y is missing. Highlighted below.

function calculatevalue (x, y)
(
var v = x+y;
     return v;
}

Question 4

Answer: Highlighted changes below.

newPrice = CurrentPrice + CurrentPrice * 0.10;
display (“New ” + newPrice);

Question 5

Answer: Highlighted changes below

int average(int a, int b) {      return (a + b )/ 2;      }