CISC Homework H03
Introduction
In this assignment, use regular expressions to validate your input in the form and use math to format your output on the web
application.
You have already converted your currency to ten different other possible currencies, but the format still looks a little funny.
You might have too many decimals if you are converting to or from USD, or your output may be incorrectly formated
(e.g. "$1.3USD" is the same numerical value as "$1.30USD," but it doesn't look the same when
output as a String
.
- A working version of your web application from H02
- Basic mathematical concepts of shifting decimal places.
- Knowledge about regular expressions and their use in JavaScript: See
www.javascriptkit.com
Overview
In this assignment, you will:
- Get completely familiarized with simple regular expressions and their usage in JavaScript
- Use simple mathematical procedures to format the output of currency to 7 significant digits
- Use an
if
statement to format the output of currency
Step-by-Step Instructions
Step 1: Reading
Even More Reading.... Get familiar with regular expressions and brush up on shifting decimals.
Step 2: Review and study the holes in the code to get familair for what the assignment is asking you to do.
Pay special attention to the converter.js
file and how the code calls the initializing functions.
Step 3: Proceed with filling in the JavaScript code in the converter.js file marked by the indicators below
*1*
- Use simple mathematical decimal and digit shifting to do ensure that your answer only has 7 significant digits
- Use an
if
statement format output according tothe following specifications:
- Conversions with no decimal value should end in ".00"
-
Conversions should have at least two significant figures. So, output ending in, say, ".9"
should really end in ".90"
-
Ensure that your output for your currency is formatted correctly according to the actual currency.
(e.g. USD = $DDD.CC)
Step 4: Proceed with filling in the JavaScript in the validation() function
*2* — Use regular expression to validate the user input for your given currency. Return true if the regular expression and matches the
input and false otherwise.
Grading Rubric (65 pts total)
Item |
Description |
Points |
Correct regular expression validation |
Refer to above references for specifications |
20 |
Correct output for your currency |
Use if statements and correct math logic |
20 |
JavaScript code |
Your Java code works and is well commented and structured |
15 |
Scripting and Submitting |
You followed instructions for scripting and submitting |
10 |
TOTAL POINTS |
|
|
Due Date: TBA