0% found this document useful (0 votes)
85 views

20 Points Triangle Problem

This document provides instructions for a lecture activity assignment involving two programming problems - a triangle classification problem and a credit card validation problem modulo 10. Students are asked to: 1) Draw the control flow graph and list independent paths for each problem 2) Develop test cases based on the independent paths 3) Develop JUnit test cases for each problem 4) Identify any bugs in the credit card validation problem and correct it Students are to submit a PDF with their answers for parts A-D along with their JUnit test cases and corrected code for part E in a zip file.

Uploaded by

Steven Tran
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views

20 Points Triangle Problem

This document provides instructions for a lecture activity assignment involving two programming problems - a triangle classification problem and a credit card validation problem modulo 10. Students are asked to: 1) Draw the control flow graph and list independent paths for each problem 2) Develop test cases based on the independent paths 3) Develop JUnit test cases for each problem 4) Identify any bugs in the credit card validation problem and correct it Students are to submit a PDF with their answers for parts A-D along with their JUnit test cases and corrected code for part E in a zip file.

Uploaded by

Steven Tran
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like