0
我只是想知道以下代碼中的陳述覆蓋率/決策覆蓋率/條件覆蓋率有什麼區別。白盒測試
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. if語句中沒有大括號。
For循環中應該有大括號。那是對的嗎? –