0

I was just wondering what is the difference between the statment coverage/decision coverage/condition coverage from the following code.

public static void main (String args [])

{    
char letter=' ';    
String word= "", vowels = "aeiouAEIOU";    
int i, numVowels= 0, numCons= 0, wordLength= 0;    
word = JOptionPane.showInputDialog("Input a word: " );    
if (word.length() > 10 || word.length() < 3)
   word = JOptionPane.showInputDialog("Input another word: ");    
wordLength= word.length();    
for (i = 0; i < wordLength; i++)    
   letter = word.charAt(i);    
   if (vowels.indexOf(letter) != -1)    
   numVowels = numVowels+1;    
numCons = wordLength-numVowels;    
JOptionPane.showMessageDialog(null, "Number of vowels: "+ numVowels);
JOptionPane.showMessageDialog(null, + " Consonants: " + numCons); 

}

P.S. There are no braces in any of the if statements.

Lucifer
  • 29,392
  • 25
  • 90
  • 143

1 Answers1

0

Different tools use a slightly different terminology to explain these numbers . For ex jacoco uses the following terminology http://www.eclemma.org/jacoco/trunk/doc/counters.html

It might be helpful if you could tell us the tool that you are using to calculate the coverage. We can then apply it to your code

Biswajit_86
  • 3,661
  • 2
  • 22
  • 36