Use ctrl + or - or if in microsoft word, use the zoom tool
public static void main()
{
String s = Console.ReadLine();
int len = s.length();
Char startletter = s[0];
Char endletter = s[len-1];
string midletter = ‘’;
if(len % 2 ==0)
midletter = s[len/2] + s[(len/2) +1]
else
midletter = s[len/2];
Console.WriteLine(startletter + midletter + endletter);
}
Here the logic is that, startletter is obtained using the index ‘0’, the last letter is obtained by calculating the “length of the string” and subtract 1 to get the “last index” of the given string.
Middle letter is calculated by first finding whether the given string length is “odd or even” and based on that index(es) are identified.
Answer:
Hi!
<em>// First you have to initialize the variables.</em>
int hits = 0;
int atbats = 0;
float percentaje = 0;
function eligible() {
hits = inputHits(); <em>// Function that input the hits.</em>
atbats = inputAtBats(); <em>// Function that input the at bats.</em>
percentaje = hits/atbats; <em>// Now, you can calculate the percentaje.</em>
if( percentaje > 0.300) { <em>//If percentaje if greater than .300 will print Eligible for the All Stars Game.</em>
print('Eligible for the All Stars Game.');
} else { <em>//Otherwise will print Not elegible.</em>
print('Not elegible.');
}
}
}
Explanation: