CSE 464 : Fall 2019
Lecture Activity (10/04/2019)
20 Points
Due: by 11:59 pm on Friday 4 - No late submissions will be accepted
th
1. Triangle Problem
public static String Triangle_Test(int a, int b, int c)
{
final int MIN = 1;
final int MAX = 200;
if(a < MIN || a > MAX)
return "value of a is out of range";
if(b < MIN || b > MAX)
return "value of b is out of range";
if(c < MIN || c > MAX)
return "value of c is out of range";
if(a < b+c && b < a+c && c < a+b) { // if triangle
if(a == b && b == c)
return "Equilateral";
else if(a != b && a != c && b != c)
return "Scalene";
else
return "Isosceles";
} else
return "Not a triangle";
a) Label the above code with node numbers for the CFG
b) Draw the CFG
c) Identify and list independent paths
d) Develop test cases based on (c) above
e) Finally, develop Junit test cases
Submission: For parts (A) – (D) develop a PDF document that contain answers. For
part (E) submit your Junit test cases and the corrected Java program. Finally make a zip
file containing your answers and submit online.
2. Is Mod 10 Program
public static boolean IsValidMod10Number(String number)
{
int [] numberArray = new int[number.length()];
boolean checkBit = false;
int sumTotal =0;
for(int i=0; i < number.length() ; i++)
{
numberArray[i] = (int) number.charAt(i);
}
for(int index = numberArray.length -1 ; index >= 0 ; index--)
{
if(checkBit)
{
numberArray[index] *=2;
if(numberArray[index] > 9)
{
numberArray[index] -= 9;
}
}
sumTotal += numberArray[index];
checkBit = !checkBit;
}
return sumTotal % 10 ==0;
}
(A) Develop the control flow graph for the above function
(B) Identify independent paths and list them
(C) Develop test cases based on your independent paths
(D) Develop Junit test cases to test your application based
on control flow graph
(E) This code has main bugs, identify the bug in this code
using your test cases and correct it.
Submission: For parts (A) – (D) develop a PDF document that
contain answers. For part (E) submit your Junit test cases and
the corrected Java program. Finally make a zip file containing
your answers and submit online.