Text arrives in whatever case the person typed. Apex can rewrite that case for you, and it can compare two values while ignoring case entirely.
String personName = 'Ada Lovelace'; System.debug(personName.toUpperCase()); // ADA LOVELACE System.debug(personName.toLowerCase()); // ada lovelace
Both methods return a NEW string. The original personName is unchanged, because strings in Apex are immutable.
capitalize() upper cases the first character and lower cases everything after it:
System.debug('gOLD'.capitalize()); // Gold
equalsIgnoreCase() compares two strings while treating upper and lower case as the same:
System.debug('Gold'.equalsIgnoreCase('GOLD')); // true
A common pattern is to clean the input first. trim() removes surrounding whitespace, and lower casing puts every value into one shape:
String entered = ' Gold '; String cleaned = entered.trim().toLowerCase(); System.debug(cleaned); // gold
Do not call toUpperCase() on a value that may be null. Guard with String.isBlank() first. Also remember that whitespace is not case: ' gold ' and 'GOLD' are still different until you trim them.
The same value gets typed by many different people in many different ways. Normalizing case is how you make GOLD, Gold, and gold behave as one value.