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

Write conditions for each of the following, making sure it works for all cases:

ID: 3594491 • Letter: W

Question

Write conditions for each of the following, making sure it works for all cases:

1 name (a string, possibly empty) starts with one of {a,b,c,d,e}

2 name starts with one of {a,b,c,d,A,B,C,D}

3 name starts and ends with with one of {a,A}

4 n (an int) is positive and even

5 n is at most 230 (so it can be doubled without overflow, assuming 32-bit ints)

6 The point (x,y) in the Cartesian plane is outside a circle of radius r (x,y,r are doubles). Hint: what is the equation of a circle?

7 Write a driver program to test the above conditions. i.e., input a name (or n), evaluate the condition, and output the result of the condition.

8 Modify the driver to iterate so that you can run multiple test vectors.

// C++ , if it's hard to write a code then please show me the pseudocode or even explain how should I do it. tnx.

Explanation / Answer

1)

len = str.length
if len != 0 :
   ch = str[0]
   switch(ch)
   {
       case 'a':
       case 'b':
       case 'c':
       case 'd':
       case 'e':
           print "Yes"
           break
       default:
           print "No"
           break
   }

2)


len = str.length
ch = str[0]
switch(ch)
{
   case 'a':
   case 'b':
   case 'c':
   case 'd':
   case 'A':
   case 'B':
   case 'C':
   case 'D':
       print "Yes"
       break
   default:
       print "No"
       break
}


3)

len = str.length
begin = str[0]
end = str[len - 1]
if (begin == 'a' and end == 'a') or (begin =='A' and end == 'A'):
   print "true"
else
   print "false"

4)

if n>0 and n%2==0:
   print "yes"
else
   print "no"

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote