Show Bid Request
Repetition Structure
Bid Request Id: 2276
|
|
|
Posted by: |
Nubcc (2 ratings)
(Software buyer rating 10)
|
Posted: |
Sep 4, 2001 2:15:43 AM EDT
|
Bidding Closes: |
Sep 6, 2001 4:00:00 AM EDT
|
Viewed (by coders): |
232 times
|
|
|
|
Description:
Create a VB application that allows the user to convert integers (in base 10 or decimal form) to integers in base 2 form (binary numbers). The application should also be able to do the reverse, that is, convert binary numbers to their equivalent decimal form.
Deliverables: The interface consists of two text boxes (labelled Decimal and Binary and four command buttons (labelled To Binary, To Decimal, Exit and About). There is also a checkbox that restricts the binary conversion to 8 bits. The user enters a decimal integer into the textbox labelled Decimal and clicks the To Binary button. The number is converted to a binary bitstring and the result is displayed in the textbox called Binary. Alternatively the user could enter a binary integer into the textbox labelled Binary and click the button called To Decimal. The bitstring is converted to decimal form and displayed in the textbox called Decimal.
The application should also:
set the default button to the To Binary or To Decimal button based on whether the user is entering data into the corresponding textbox. The default button is the button that responds to the Enter key. An application can only have one default button. set the tab index property for all objects to control the order of entry using the Tab key. Error messages should be generated when:
the user enters a negative number into the Decimal textbox and attempts to convert it to a binary bitstring. the user enters a number greater than 255 into the Decimal textbox and attempts to convert it to a binary bitstring when the restrict to 8-bits checkbox is set. the user enters a string that is not a binary number into the Binary textbox and attempts to convert it to a decimal integer. the user enters a bitstring with more than 8 bits into the Binary textbox and attempts to convert it to a decimal integer when the restrict to 8-bits checkbox is set. the user tries to convert an empty textbox.
This is an exercise primarily in the use of repetition and selection structures in VB. You should find that as you develop a solution for this assignment that you need to make use of both the FOR...NEXT loop and the DO...LOOP UNTIL structures. In addition you will need to create and use both local and form-level variables.
Algorithms
In applications, binary numbers are displayed as strings, eg. "01101". There is no binary number datatype for such strings. We therefore need to be able to assemble the bitstring for each decimal integer. For example, the decimal number 20 is converted into the bitstring "10100". When going the other way, we need to be able to convert the bit string back into an integer value. For example, the bitstring "10111" is convreted into the integer value 23. The following calculations are needed to be performed within this application.
Converting a Decimal Integer to Binary (Method 1) This method can only be used on positive, integer values. It relies on knowing the length of the binary number in bits.
set the bitstring to nothing
for each bit required in the bitstring
Calculate the remainder when the number is divided by 2
Number = Number \ 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
next bit
output the bitstring
Converting a Decimal Integer to Binary (Method 2) This method can only be used on positive, integer values. It can be used to produce bitstrings of any length.
set the bitstring to nothing
repeat
Calculate the remainder when the number is divided by 2
Number = Number \ 2 (integer division)
Bitstring = Remainder concatenated with the Bitstring
until the Number is zero
output the bitstring
Converting a Binary bitstring to Decimal This method assumes that the bitstring represents a valid binary number.
Number = 0
for each character in the bitstring
Determine the value of the bit
Number = Number * 2 + Value of the bit
next character (moving rightwards through the bitstring)
output the Number
Some Necessary VB Concepts
The solution for this application will require some additional VB concepts.
To identify the length of a string of characters use the Len function. For example, iLen = Len(MyString) where iLen is an integer variable, MyString is a string variable and Len is the function. Therefore, the value of Len("10111") is 5. To isolate one character in a string of characters use the Mid function. For example, sChar = Mid(MyString, iCount, 1) where sChar is a string variable, MyString is a string variable, iCount is the character you want and 1 is how many characters to extract. Therefore, the value of Mid("abcdefghij", 4, 2) is "de".
Requirements
Complete the application using the following specifications:
You must use an algorithm to convert decimal to binary and binary to decimal. Any assignment that uses built-in functions or 3rd party functions to perform these tasks will be deemed unacceptable. All components of the interface must be assigned a name. The form should start in the centre of the screen and have a fixed border size. The form Minimize button should be enabled but the form Maximize button should be disabled. The Exit button should have the "Alt key" designator set to the character "x". The About button should have the "Alt key" designator set to the character "A". The default property of the To Binary and To Decimal command buttons must be appropriately set during runtime.
Special Conditions / Other:
This needs to be submitted with the 2 frm's and vpb
Remember that contacting the other party outside of the site (by email, phone, etc.) on all business projects < $500 (before the buyer's money is escrowed) is a violation of both the software buyer and seller agreements.
We monitor all site activity for such violations and can instantly expel transgressers on the spot, so we thank you in advance for your cooperation.
If you notice a violation, you can report it to: abuse@rentacoder.com.
|
|
Bidding/Comments:
|
All monetary amounts on the site are in United States dollars.
Rent a Coder is a closed auction, so coders can only see their own bids and comments. Buyers can view every posting made on their bid requests. |
See all rejected bids (and all comments)
Name |
Bid Amount |
Date |
Coder Rating |
|
|
This bid was accepted by the buyer!
|
$15 (USD)
|
Sep 4, 2001 4:54:42 AM EDT
|
10
(Excellent)
|
|
|
I can have this done in no time. Give me the word and I'll get started right away. |
|
|
|
|
|