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

// 1) howSwedish //ABBA is a band, they have many songs including Dancing Queen,

ID: 3744119 • Letter: #

Question

// 1) howSwedish //ABBA is a band, they have many songs including Dancing Queen, and // Fernando. ABBA is actually a Swedish band, so if we wanted to find // out howSwedish a String is, we could simply find out how many times // the String contains the substring "abba". We want to look for this // substring in a case insensitive manner. So "abba" counts, and so //does "aBbA". We also want to check for overlapping abba's such as // in the String "abbAbba" that contains "abba" twice. /IhowSwedish("AbBa a b b a") returns 1 // howSwedish("abbabba!") returns 2 /TODO: Complete this method // Use str.length) // Use for concatenation // Use var to declare variables // The following asserts will fail until howSwedish is fixed //console.assert 1 - houwedish aoxc Aba xXx- ) ): // console.assert ( 1= howSwedish ( 'axxc AbBa XX. ) ); console.assert 2howSwedish 'ABBA') ); console.assert 0howSwedish 'xx' ) ); console.assert 1 howSwedish 'ab'); console.assert 1howSwedish axbxbxa' )); // Add at more test cases

Explanation / Answer

public static int howSwedish(String str) { int count = 0; for(int i = 0; i