public class CreditCardTest1
{
public static void main(String args[])
{
String creditCard = args[0].toUpperCase();
if(creditCard.equals(AllowedCreditCard.VISA.name() ))
{
System.out.println("Your credit card" + args[0] + "is accepted.");
}
else if(creditCard.equals(AllowedCreditCard.MASTER_CARD .name()))
{
System.out.println("Your credit card" + args[0] + "is accepted");
}
else if(creditCard.equals(AllowedCreditCard.AMERICAN_EX PRESS.name()))
{
System.out.println("Your credit card" + args[0] + "is accepted");
}
else
{
System.out.println("Sorry we do not accept the credit card" + args[0] +
"at this time");
}
}
}
/*class AllowedCreditCard
{
protected final String card;
public final static AllowedCreditCard VISA = new
AllowedCreditCard("VISA");
public final static AllowedCreditCard MASTER_CARD = new
AllowedCreditCard("MASTER_Card");
public final static AllowedCreditCard AMERICAN_EXPRESS = new
AllowedCreditCard("AMERICAN_EXPRESS");
private AllowedCreditCard(String str)
{
card = str;
}
public String getName()
{
return card;
}
}*/
enum AllowedCreditCard
{
VISA, MASTER_CARD, AMERICAN_EXPRESS
}