Your problem is that you don't put anything in the String customerType. Just add the commented line.
import java.text.NumberFormat;
import java.util.*;
public class ValidatedInvoiceApp
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String choice = "y";
while (!choice.equalsIgnoreCase("n"))
{
// get the input from the user
double subtotal = 0.0;
String customerType = "";
System.out.print("Enter customer type (r/c/t): ");
////////////////////customerTyper = sc.nextLine();
if (sc.hasNext())
{
if (customerType.equalsIgnoreCase ("r") || customerType.equalsIgnoreCase ("c") || customerType.equalsIgnoreCase ("t"))
{
customerType = sc.next();
}
else
{
sc.nextLine();
System.out.println("Error! Invalid Customer Type. Please Try Again. \n");
continue;
}
}
else
{
System.out.print("Enter subtotal: ");
subtotal = sc.nextDouble();
double discountPercent = getDiscountPercent(customerType, subtotal);
// calculate the discount amount and total
double discountAmount = subtotal * discountPercent;
double total = subtotal - discountAmount;
// format and display the results
NumberFormat currency = NumberFormat.getCurrencyInstance();
NumberFormat percent = NumberFormat.getPercentInstance();
System.out.println(
"Discount percent: " + percent.format(discountPercent) + "\n" +
"Discount amount: " + currency.format(discountAmount) + "\n" +
"Total: " + currency.format(total) + "\n");
// see if the user wants to continue
System.out.print("Continue? (y/n): ");
choice = sc.next();
System.out.println();
}
}
}
private static double getDiscountPercent (String customerType, double subtotal)
{
// get the discount percent
double discountPercent = 0;
if (customerType.equalsIgnoreCase("R"))
{
if (subtotal < 100)
discountPercent = 0;
else if (subtotal >= 100 && subtotal < 250)
discountPercent = .1;
else if (subtotal >= 250 && subtotal < 500)
discountPercent = .25;
else
discountPercent = .30;
}
else if (customerType.equalsIgnoreCase("C"))
{
discountPercent = .20;
}
else if (customerType.equalsIgnoreCase("T"))
{
if (subtotal < 500)
discountPercent = .40;
else if (subtotal >= 500)
discountPercent = .50;
}
return discountPercent;
}
}