THE MAIN PROBLEM is the method substring() is not found
I'm coding a shop where a <list>
of products has already been initialized & all the user has to do is type in the name of the product they want to buy and the number. One of the specifications is that the user types the name of the product correctly e.g. Blue Pen but it should also work if they type in the correct product but with incorrect capitalization e.g. BluE PeN.
I'm trying to use the substring() method to sepearate and capitalize the first letter of the user input (with the toUpperCase() method) and the toLowerCase() for the rest.
private void sell() {
Product product = getProductByName(readName());
product = product.substring(0,1).toUpperCase() + product.substring(1).toLowerCase();