I have a problem with case sensitive input
my options are s and b and how to make a program when I input capital B or S to continue?
// options for selling and buying stocks
System.out.println("\n");
System.out.println("Options as single upper or lower case character : ");
System.out.println("\tB to buy the stock");
System.out.println("\tS to sell the stock");
System.out.println("\tAny other character to exit!\n");
System.out.println("Enter Option : ");
String options = in.next();
boolean finished = false;
String brakeit = null;
// while loop for stock market simulation
while (!finished) {
// switch case selection structure
switch (options) {
// buy stocks
case "b" :
{
if (stocks.calcCommission() > 500)
{
System.out.println("Cost of Shares : " + formatter.format(priceS * shareS));
System.out.println ("Commision : 500.00 ");
System.out.print ("Total Cost : " +formatter.format(stocks.NewcalcValue() + stocks.newcalcCommision()) );
System.out.println("\n");
finished = true;
System.exit(0);
}
else
{
System.out.println("Cost of Shares : " + formatter.format(priceS * shareS));
System.out.println ("Commision : " + formatter.format(stocks.newcalcCommision()));
System.out.print ("Total Cost : " + formatter.format(stocks.NewcalcValue() + stocks.newcalcCommision()));
System.out.println("\n");
finished = true;
System.exit(0);
} // end if else for buying stocks
}
// sell stocks
case "s" :
{
if (stocks.calcCommission() > 500)
{
System.out.println("Receipts : " + formatter.format(priceS * shareS));
System.out.println ("Commision : 500.00 ");
System.out.print ("Net Receipts : " + formatter.format(stocks.NewcalcValue() + stocks.newcalcCommision()));
System.out.println();
finished = true;
System.exit(0);
}
else
{
System.out.println("Receipts : " + formatter.format(priceS * shareS));
System.out.println ("Commision : " + formatter.format(stocks.newcalcCommision()));
System.out.print ("Net Receipts : " + formatter.format(stocks.NewcalcValue() + stocks.newcalcCommision()));
System.out.println("\n");
finished = true;
System.exit(0);
} // end if else for selling stocks
break;
}
}
//loop scanner
Scanner in2 = new Scanner (System.in);
options = in2.next();
// if user enters any character except s and b
if (!options.equalsIgnoreCase("s") && !options.equalsIgnoreCase("b"))
{
finished = true;
System.exit(0);
// end if
} // end while