(Solved) : Aline Odd Number Characters Print Line Odd Number Characters Otherwise Print Two Middle Ch Q44030273 . . .
If aLine has an odd number of characters, print “The line has an odd number of characters.” Otherwise, print the two middle characters of aLine. when I plug in ” This line starts with a blank” I get ts but the key says rt. (num is defined as the length of the string)int middle1 = num / 2;int middle2 = (num / 2)-1;char atMiddle1 = temp.charAt(middle1);char atMiddle2 = temp.charAt(middle2);if (num % 2 != 0) { System.out.println(“The line has an odd number of characters.”);} else System.out.println(“The two middle characters are ” + atMiddle1+atMiddle2);
Expert Answer
Answer to If aLine has an odd number of characters, print “The line has an odd number of characters.” Otherwise, print the two mi…
OR