Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Java - Membership

samjhana01
samjhana01 


REGISTERS Attachments Tags Clarifications

Answers

Java - Membership - Solution

dickersonka
dickersonka 



Attached is the solution including source and comments to the 4 exercises for the membership assignment. Attachments
Membership.zip (3 K) Download
Preview
false; //validate credit card if(creditCard != null) isValid = creditCard.validateCard(); //invalid card if(!isValid){ System.out.println("Invalid credit card number"); return; } int charge = 0; //get charge for membership if(membershipType.equalsIgnoreCase("R")){ charge = 20; } else if(membershipType.equalsIgnoreCase("P")){

Preview
static void main(String[] args){ //scanner for input Scanner input = new Scanner(System.in); //prompt for membership type System.out.println("Membership Types"); System.out.println("Regular - $20.00"); System.out.println("Premium - $50.00"); System.out.print("Pick a membership (R/P): "); String membershipType = input.nextLine(); //prompt for visa/mastercard System.out.print("Paying with

Preview
validateVisa(ccNumber); } else if(ccType.equalsIgnoreCase("M")){ isValid = validateMastercard(ccNumber); } //invalid card if(!isValid){ System.out.println("Invalid credit card number"); return; } int charge = 0; //get charge for membership if(membershipType.equalsIgnoreCase("R")){ charge = 20; } else if(membershipType.equalsIgnoreCase("P")){ charge =

Preview
charged: $" + charge); } //master card sub class class MasterCard extends CreditCard{ public MasterCard(String ccNumber) { super(ccNumber); } @Override boolean validateCard() { String firstTwo = getCcNumber().substring(0, 2); //validate starts with 51-55 and 16 in length

Screenshots
Purchase Answer