Only need to do “Project #2-3: Creating a simple (fake) credit card verification”, the rest is not my part. Here are the framework and requirement.
Project 2: Valida0ng and Processing User Input
(Overview and Dra= Submission)
Overview: You will be assigned 1 of 8 projects. Each project requires crea;ng a form to collect data,
valida;ng the data entered, and then processing the data to produce a final result. As part of the
processing step, you will use condi;onal logic to implement excep;ons to the regular final result.
Schedule: You will create this project across three homework assignments:
• Lab 4: By Lab #4, you will flowchart at least one of your two form valida;on and processing
func;ons. We also recommend that you aKempt to create your input form so that we can give
you feedback. You should not worry about JavaScript for this deadline!
• Dra=: By a deadline set by your instructor around Class #5, you will implement your input form
and at least one of your two form processing func;ons. For this deadline, you will priori;ze
ensuring that your flowchart and your code implementa;on match!
• Final: By a deadline set by your instructor around Class #6, you will implement all parts of the
project, update your code and flowchart to ensure that they match, and provide us with a
complete list of values required to thoroughly test your project. In addi;on, you may aKempt
some bonuses (worth points!) that will be revealed aWer the draW homework deadline!
An important note about style:
As men;oned in the first week, every programmer develops their own dis;nc;ve style. Although we
provide you with some strict guidelines in this course for things like variable naming, indenta;on and
line spacing, and some commen;ng, there are many ways that your own style will show through.
This also applies to your flowcharts. Although we provide you with examples, you will develop your
own ways of phrasing (in English, not JavaScript!) each step and condi;on, and you will develop your
own sense of how much to summarize into a single “step”. If your coding or flowchar;ng style appears
too close to our examples, or if either appears too close to that of another student, you will lose points.
In order to become a good coder (or at least good enough to pass this class!) you need to move beyond
copying the models we provide. Study the model and make sure that your work doesn’t contradict the
model, but do not blindly copy the models! Especially do not start by modifying a copy of our example
PDF. We will know if you do, and you will lose points!
Part 1: Flowchar0ng
Please see the Lab #4 assignment for more details on this step. Although Lab #4 only requires you to
complete part of your flowchart, you must flowchart logic for both if your func;ons before coding it.
Part 2: Design Form
Paying aKen;on to the types of data that you’re asked to collect, choose the best form input type for
each prompt (select menu or basic input). Use the provided Prompts to label the fields.
Use the Op0ons / Constraints column to determine what values to allow. How you constrain these
values is mostly up to you, but bear in mind two things:
1. The focus of this project is condi0onal logic, so while you can constrain some choices through
HTML (for example, popula;ng a select menu with the list of op;ons, which we signal is
appropriate by providing you with a semicolon-separated list in the Op0ons column), most of
your constraints should probably be handled in your form valida;on step. NOTE: We strongly
urge you to only use select menus and input fields on this project. Checkboxes and radio buCons
are mostly inappropriate for this project, in addiFon to being more difficult to use.
2. You need to make sure that your selected input type will support the user entering valid data.
For example, a text field of type “number” might not accept certain formacng requirements
that we have requested (such as numbers with leading 0s or numbers with dashes in the
middle). You also want to make sure that the user can enter invalid data for any place that we’ve
asked you to provide user feedback (such as if the user enters too short a number or too long a
name). NOTE: If you have any doubts, just use input type=”text”, since this will work for all
freeform inputs (i.e., everything except your select menus)
If you get this part done before the deadline for your Lab #4, we will give you feedback on the form
design, but the form will not be graded un;l the Dra= deadline.
Part 3: Dra= Code
AWer you plan out your code in a flowchart and design your form, you can begin coding the project. We
will provide you with starter code in your next lab mee;ng, but if you want to get started sooner, you
can begin from one of the Class #4 examples about form valida;on, since they are built on the almost
the same starter code as this project’s.
The goal for your dra= version of the project is to complete at least one of the two main func;ons that
you’re wri;ng.
If you complete only the validateData() func;on for your draW, then please temporarily add an output
func;on call that will output “All form data is valid” only when the form data is valid – i.e., when you
are returning true from this func;on. (When the form data is invalid, you should tell the user what is
wrong via an output message that you’ll write as part of the assignment, bearing in mind that part of
the grade is for clarity and accuracy in your messages).
If you complete only the evaluateAnswers() func;on for your draW, then please temporarily add an
output func;on call to the validateData() func;on that says “Currently assuming all data is valid” and
make sure that the validateData() func;on temporarily always returns true. (This is necessary so that
the code we have wriCen for you will call the evaluateAnswers() funcFon).
For the validateData() func;on, make sure that the user’s input follows the constraints we have
provided. If the input does not fit the constraint, output an appropriate error message and return false.
For example, if the user is supposed to enter a 5-digit ZIP code and enters more or fewer digits, you
might output “Please enter a five-digit ZIP code”. To be thorough for this par;cular requirement, you
should also make sure that the user only enters numbers instead of leKers or other characters. You can
provide the same error message (“Please enter a five-digit ZIP code”) or you can provide a custom one
for the second condi;on (such as “Please enter only numbers”). TIP: For the final version of this project,
there will be bonuses available for parFcularly thorough handling of user input.
For the evaluateAnswers() func;on, there are a few parts of your instruc;ons to consider:
Excep0ons or Condi0ons (name varies by assignment): These are rules for processing the user’s data.
Some should return false and give the user a reason the data couldn’t be processed (for example, some
projects include an excep1on that a food item can’t be ordered in certain ZIP codes). Others should
somehow change the data (for example, some projects include a condi1on or excep1on that the
customer’s order price should be modified depending on certain condiFons), or add to the result (for
example, some projects specify that you should add some other message as part of the final output)
Addi0onal Calcula0ons (not included in every assignment): This is addi;onal informa;on that you need
for your final result output. You may need to create addi;onal variables to track this informa;on, or
you may be able to just do addi;onal calcula;ons. For example, if your assigned project involves
calculaFng a price, we have provided you with a list of item prices.
Results: This is the final output if the user’s input leads to a valid result. The output is shown in blue
text, with variables or addi;onal condi;ons wriKen in underlined italics. For example, “Your order of
item quanFty item ordered” means that you would output something like “Your order of 3 hamburgers”
(with 3 being the item quanFty and hamburgers being the item ordered). Another example: “If a
discount was given, add: This includes a 25% discount” means check if the user received a discount as a
result of some condi;ons in your program; if so, add “This includes a 25% discount” to the output text.
TIP: There are mulFple ways to check if a condiFon was met earlier in your program. For the dra4, we
are not looking for the most efficient soluFon, but rather the soluFon that you understand best.
REMINDER: You have not yet learned how to do some of the String processing required for this
assignment. You can plan out the logic for doing it in your flowchart (and in code comments, if you
want) before learning the String processing methods, which will be covered in Lab #4.
Part 4: Prepare for dra4 submission
• Add code comments explaining your condi;onal logic and calcula;ons in English. These
comments should be brief mul;-line comments above the related logic, or end-of-line
comments on the same line as the related logic. Remember, end-of-line comments should only
be a few words long, so if you need to write more, use a mul;-line comment!
• Ensure that your code is neatly formaKed with proper indenta;on and spacing
• Ensure that your variables are all clearly named and camelCased. You may use short names for
temporary variables, but you should provide an end-of-line code comment explaining what the
temporary variable is for.
• Make sure that your flowchart has been updated to match your coding so far (we will only check
that it matches code you’ve wriKen; the rest of the flowchart we will just check for logic)
• Export your flowchart as a PDF named (exactly) flowchart.pdf and place it in your project folder
(TIP: If using the draZ template that you receive in lab, you can click the “View My Flowchart”
link to make sure you did this step right)
• Upload your draW project so that it appears on your web space at
digitalmedia.neu.edu/YourUserName/project2/dra=
Project #2-1: Crea;ng a very simple (fake) food ordering system.
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
Prompt
Which combo are you ordering?
How many are you ordering?
ZIP code
Op0ons / Constraints in Valida0on Step
Pizza & Salad; Hamburger & Fries; Taco PlaKer
Whole number greater than 0
Exactly 5 digits (even if 0 is first digit)
Excep0ons (Processing Step):
Excep0on
Pizza & Salad op;on not available on the
West Coast (ZIP codes with first digit 9)
Discount the price by 25% if Hamburger &
Fries or Pizza & Salad is selected and the user
has ordered 3 or more.
Result
“Due to the e. coli outbreak, Pizza & Salad is not
available in this region.” Do not complete order.
Price calculated (see below) with 25% discount
and properly rounded to dollars and cents.
Complete order with this output.
Addi0onal Calcula0ons (may require addi;onal variables):
Pizza & Salad costs $12.00
Taco PlaKer costs $10.00
Hamburger & Fries costs $8.00
Results (Calculate and show output if Processing Step successful – For this step, italicized underlined
items represent data that must be included or condiFons that must be checked.)
Your order of item quanFty item ordered will be available at our store loca;on in ZIP code zip
code. You will be charged final price, formaCed as $D.CC when you pick it up. If a discount was
given, add: This includes a 25% discount for ordering item quanFty of this item.
Notes:
$D.CC means format the money as US currency, with $ followed by the dollar amount, then a period,
then the amount in cents (which must always be 2 digits!) We will cover how to do this in lab.
Project #2-2: Crea;ng a very simple (fake) meal combo ordering system
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
Prompt
Please select the first item for your meal
combo:
Please select the second item for your meal
combo:
ZIP code
Op0ons / Constraints in Valida0on Step
Pizza, Salad, Burger, Fries
Pizza, Salad, Burger, Fries – must not be the same as
first item selected!
Exactly 5 digits (even if 0 is first digit)
Excep0ons (Processing Step):
Excep0on
Orders cannot be placed in the Virgin Islands
(ZIP codes 00801 to 00851)
Discount the price by 25% if the two items (in
either order) are Hamburger and Fries
Result
“Unfortunately, ordering is not yet available in the
Virgin Islands” Do not complete order.
Price calculated (see below) with 25% discount and
properly rounded to dollars and cents. Complete
order with this output.
Addi0onal Calcula0ons (may require addi;onal variables):
Pizza costs $4.00
Salad costs $3.00
Hamburger costs $5.00
Fries cost $2.00
Results (Calculate and show output if Processing Step successful – For this step, italicized underlined
items represent data that must be included or condiFons that must be checked.)
Your item 1 & item 2 combo will be delivered to your address on file in ZIP code zip code. The
total price will be final price, formaCed as $D.CC. If burger and fries were selected, add: This
includes a 25% discount for our current special combo.
Notes:
$D.CC means format the money as US currency, with $ followed by the dollar amount, then a period,
then the amount in cents (which must always be 2 digits!) We will cover how to do this in lab.
Project #2-3: Crea;ng a simple (fake) credit card verifica;on
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
TIP: Remember, 0 might be the first digit for any of these numbers!
Prompt
Please select your credit card type:
Please enter your credit card number:
Please enter 4-digit valida;on code
Please enter your ZIP code
Op0ons / Constraints in Valida0on Step
Charicard, Gengcard
If Charicard, must be exactly 6 digits. If Gengcard,
must be exactly 8 digits.
Exactly 4 digits
Exactly 5 digits
Excep0ons (Processing Step):
Excep0on
First 2 digits of valida;on code do not
equal the sum of the individual digits in
the credit card number
Last 2 digits of valida;on code must be
the sum of the individual digits in the zip
code.
Error Message (if answers violate a rule)
“Your valida;on code does not match this credit
card number.”
“Your valida;on code does not match your
address.”
Results (What to show if all answers evaluated successfully)
Your credit card informa;on has been saved successfully. Happy Shopping!
Project #2-4: Crea;ng a very simple (fake) system for ordering collectable cards
TIP: Remember, 0 might be the first digit for any of the numeric inputs!
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
Prompt
Which “Magic: The Gathering” card pack do
you want to purchase?
Please enter your credit card number:
Please enter your credit card valida;on (CCV)
code:
Op0ons / Constraints in Valida0on Step
Retail booster pack; Collectable starter pack; 1st
edi;on complete set
Exactly 6 digits
Exactly 3 digits
Excep0ons (Processing Step):
Excep0on
First digit of the CCV is not the total of the
first 2 digits of the credit card number
Second digit of the CCV is not the total of the
3rd and 4th credit card digits
Third digit of the CCV is not the total of the
5th and 6th credit card digits
1st edi;on complete set is ordered
Retail booster pack is ordered
Result
“Incorrect credit card informa;on entered.” Do
not complete order.
“Incorrect credit card informa;on entered.” Do
not complete order.
“Incorrect credit card informa;on entered.” Do
not complete order.
“Unfortunately, the price of this item exceeds
your credit limit.” Do not complete order.
Add a $2.00 shipping fee to the final price.
Complete order.
Results (Calculate and show output if Processing Step successful – For this step, italicized underlined
items represent data that must be included or condiFons that must be checked.)
Your card pack type for “Magic: The Gathering” will be delivered to you as soon as possible.
Your credit card will be billed a total of total price as $D.CC. If shipping fee was added: This
includes a $2.00 shipping fee. If no shipping fee was added: You received FREE shipping on this
order.
Notes:
$D.CC means format the money as US currency, with $ followed by the dollar amount, then a period,
then the amount in cents (which must always be 2 digits!) We will cover how to do this in lab.
Project #2-5: Crea;ng a simple (fake) giW card purchasing system
TIP: Remember, 0 might be the first digit for the ZIP code (and possibly the dollar amount, if you allow)
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
Prompt
What store do you want to buy a giW card for?
How much do you want to put on the giW card?
Please enter your ZIP code
Op0ons / Constraints in Valida0on Step
Sepharoah, Wallgrinds, Taco Hut
Amount in dollars or dollars and cents. Numbers
like 1.1 (too few digits) or 1.111 (too many
digits) should not be accepted.
Exactly 5 digits
Excep0ons (Processing Step):
Excep0on
Sepharoah giW card can only be ordered on the
East Coast (ZIP code under 34000, and not
including any that have first 3 digits 090
through 099)
Sepharoah giW card must have a minimum of
$50 put on it and can’t have more than $1,000
put on it.
Wallgrinds and Taco Hut giW cards must have a
minimum of $5 put on them and can’t have
more than $500 put on them.
Wallgrinds giW cards can only be purchased
with dollar values that are divisible by 5.
Card value purchased is under $100 and ZIP
code not in California, which has outlawed
these service fees (ZIP codes beginning with
96701 through 96898)
Result
“Sorry, the Sepharoah giW card can only be
ordered on the East Coast”
“Sorry, the Sepharaoh giW card has a minimum
or maximum value of $50 or $1,000”
“Incorrect credit card informa;on entered.”
“Unfortunately, the price of this item exceeds
your credit limit.”
Add 5% of the card value as a processing fee
Results (Calculate and show output if Processing Step successful – For this step, italicized underlined
items represent data that must be included or condiFons that must be checked.)
Your giW card for store name in the amount of card amount formaCed as $D.CC will be shipped
to your address in ZIP code ZIP code. If processing fee was added: Please note that a
processing fee of processing fee has been added to your purchase.
Notes:
$D.CC means format the money as US currency, with $ followed by the dollar amount, then a period,
then the amount in cents (which must always be 2 digits!) We will cover how to do this in lab.
Project #2-6: Crea;ng a system that judges whether a pet will like its name, based on the pet’s species
and gender. The user can enter any species, but only 3 are actually accepted.
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
Prompt
What species of pet are you
naming?
Op0ons / Constraints in Valida0on Step
Text input (NOT a select menu); only accept input that includes
“cat”, “dog”, or “pig”, not case-sensi;ve. If mul;ple animal
names are found in the user input, take the first one. Suggested
error: “Sorry, that species is not yet in our database.”
Male; Female; Unknown
Whiskers; Spot; Porky; Daisy; King; Princess
What is your pet’s gender?
Which name do you want to
choose for this pet?
Condi0ons: (Processing Step):
Rule
Only cats can be named
Whiskers
Only male pigs can be
named Porky
Only dogs and pigs that
are female or of unknown
gender can be named
Daisy
Only animals that are male
or of unknown gender can
be named King
Only female cats can be
named Princess
Error Message (if answers violate a rule)
Your pet pet species does not want to be named Whiskers; that
name is only for cats!
If non-male pig: Sorry, your pig’s gender is pet gender. Only male
pigs want to be named Porky.
If not a pig: Your pet pet species does not want to be named Porky;
that name is only for pigs!
If wrong gender: Pets of this gender don’t want the name Daisy.
If wrong species: Pets of this species don’t want the name Daisy.
If wrong gender: Pets of this gender don’t want the name King.
If wrong gender: Pets of this gender don’t want the name Princess.
If wrong species: Pets of this species don’t want the name Princess.
Rule
Any animal can be named Spot
Comment (add this if rules not violated)
But just to check does, he/she/it (gender) actually have spots?
Results (Calculate and show output if Processing Step successful – For this step, italicized underlined
items represent data that must be included or condiFons that must be checked.)
Congratula;ons on adop;ng a new pet species! We are confident he/she/it, depending on
gender will enjoy being called pet name! Add comment if animal name is Spot, as per last rule
above.
Project #2-7: Crea;ng a very simple (fake) regional pet registra;on system
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
Prompt
What species of pet are you registering?
What is the pet’s name?
What is the pet owner’s last name?
What is your 9-digit ZIP code?
Op0ons / Constraints in Valida0on Step
Cat; Dog; Ferret
3 to 10 characters; 1 name only, no spaces
2 to 20 characters; 1 name only, no spaces
Accept in form of 9 digits or as 5 digits followed
by a dash and then 4 more digits
Excep0ons (Processing Step):
Excep0on
Ferrets can’t be registered in California (ZIP
codes beginning with 90001 through 96162)
Ferrets can’t be registered in Hawaii (ZIP
codes beginning with 96701 through 96898)
Result
“Sorry, California state law prohibits ferret
ownership.”
“Sorry, due to wildlife conserva;on efforts,
ferrets are currently prohibited in Hawaii.”
Addi0onal Calcula0ons (may require addi;onal variables):
Generate a registra0on number for the pet by combining the last 4 digits of the 9 digit zip code, the
first 3 characters of the pet name, and the first 2 characters of the owner name
Results (Calculate and show output if Processing Step successful – For this step, italicized underlined
items represent data that must be included or condiFons that must be checked.)
Thank you for registering your pet species named pet name owner last name. Their
registra;on number is registraFon number.
Project #2-8: Crea;ng a simple (fake) bank transac;on confirma;on code
Form & Valida0on Step: (If valida;on fails, output a message telling the user what the problem is)
Prompt
Bank rou;ng number:
Type of transac;on:
Transac;on loca;on:
Op0ons / Constraints in Valida0on Step
Must be exactly 9 digits (likely has leading 0s!)
Treasury check; Money order; Savings bond; Local deposit
Cleveland, OH; Peoria, IL; Chicago, IL
Excep0ons (Processing Step):
Rule
If Treasury Check, Rou;ng Number must be
000000518
If Money Order, Rou;ng Number must be
one of: 000000204, 000001193, 000008002
If Savings Bond, Rou;ng Number must be
000090007
If Local Deposit, first 4 digits of Rou;ng
Number must be one listed for that
Transac;on Loca;on:
Error Message (if answers violate a rule)
“The rou;ng number is incorrect for this type
of transac;on.”
“The rou;ng number is incorrect for this type
of transac;on.”
“The rou;ng number is incorrect for this type
of transac;on.”
“The rou;ng number is incorrect for this
transac;on loca;on.”
Cleveland, OH: 0410, 0412
Peoria, IL: 0711
Chicago, IL: 0710, 0712, 0719
Addi0onal Calcula0ons (may require addi;onal variables):
Generate a 3-digit confirma0on code by adding up the individual digits in each of the 3 sets of 3 digits
in the rou;ng number (HINT: think of the number as being abc|abc|abc; the confirma;on code will be
the sum of each set of a, b, and c)
Generate a par0al view of the rou;ng number by star;ng with XXXX-X in place of the first 5 digits.
Append to this the 6th through 8th digits, then another dash, then the 9th digit, so the result will appear
like this example: XXXX-X789-0
Results (Calculate and show output if Processing Step successful – For this step, italicized underlined
items represent data that must be included or condiFons that must be checked.)
Your transacFon type has been ini;ated at our branch in transacFon locaFon using rou;ng
number parFal view (only the last 4 digits are shown, for security purposes). Your confirma;on
code is confirmaFon code.