Question: Please use notepadd + + and coding language is javascript and html . Create two appropriately labeled textboxes on your Webpage. Use the ONCHANGE attribute
Please use notepadd and coding language is javascript and htmlCreate two appropriately labeled textboxes on your Webpage.
Use the ONCHANGE attribute to convert the binary number in one box to the decimal in the other, and vice versa.
The binary number will have to be stored and represented as a decimal whose digits are constrained to the values of zero and one.
Eg binary five is stored as decimal one hundred one.
The numeric value is constrained to one byte of storage so that the maximum is a nonnegative decimal integer between zero and inclusive
The maximum binary representation is therefore
Therefore, use the alert function to complain to the user that their input data is outside the specified ranges.
Because we have restricted the number of binary digits to a maximum of eight, there is no need to use a repetition statement.
Use another alert to indicate that a digit value is illegal when expecting a binary digit ie not and not
Label each text box appropriately, ie each textbox should be labeled with its respective base and valid input range.
Eg Base
Ensure that identifiers in your code eg variable and function names are labeled appropriately.
Use a separate function for base conversion in each direction respectively.
Base your program on this Lab code template.
Extra Credit: use the JavaScript switch statement to convert either the decimal or binary value additionally to and from hexadecimal via two singlecharacter text boxes.
Thank you. i am going to attach the template
onchange base conversion template
function validateDigitInBase digit, base
if
alert;
function convertBinaryToDecimal binaryValue
Assumes that binaryValue is a decimal value where each decimal digit represents a binary digit
constants
var SOURCEBASE ;
var DESTINATIONBASE ;
var DISPLAYBASE ;
local variables
var placeValue ; initialized to the multiplicative identity
var decimalValue ; initialized to the additive identity
var digit;
digit ; extracting the rightmost DISPLAYBASE simulated binary digit
validateDigitInBase; ensuring that the new digit is valid in the SOURCEBASE
decimalValue ; adding the new digit scaled by its SOURCEBASE place value
placeValue ; updating the SOURCEBASE place value
binaryValue ; the decimal simulated binary value without the rightmost DISPLAYBASE digit
repeat the above code block seven more times
return decimalValue;
function convertDecimalToBinary decimalValue
constants
var SOURCEBASE ;
var DESTINATIONBASE ;
var DISPLAYBASE ;
local variables
var placeValue ; initialized to the multiplicative identity
var binaryValue ; initialized to the additive identity
Assumes that binaryValue is a decimal value where each decimal digit represents a binary digit
var digit;
digit ; extracting the rightmost DESTINATIONBASE digit
validateDigitInBase; ensuring that the new digit is valid in the DESTINATIONBASE
binaryValue ; adding the new digit scaled by its DISPLAYBASE place value
placeValue ; updating the DISPLAYBASE place value
decimalValue ; the decimal value without the rightmost DESTINATIONBASE digit
repeat the above code block seven more times
return binaryValue;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
