change this line :
UI.println(text + " " + product + "s text, text text text text -");
to:
UI.println(text + " " + capitalize(product) + "s text, text text text text -");
But your code needs a bit more structuring. Focus on even indentation. And if you need the capitalized product
later on, you'd better save it before you use it, like
...
product = capitalize(product);
UI.println(text + " " + product + "s text, text text text text -");
...
EDIT:
For this I'm assuming the line is contained in a String
called line
.
First check if the line
begins with product
. Then capitalize it.
...
String line = text + " " + product + "s text, text text text text -";
line = line.trim(); // removes whitespaces.
if ( line.startsWith( product ) ) {
product = capitalize ( product ); //or whatever.
}
UI.println(line);
...