


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An assignment for cs 061 students to build a data type converter program. The program should take user input of decimal integers, 2's complement binary integers, or hexadecimal numbers and convert them to the other two data types. Collaboration policy, notes, and grading policy.
Typology: Assignments
1 / 4
This page cannot be seen from the preview
Don't miss anything!
Warning: this is a lengthy program โ make sure you get an early start!!!!! Use the programs you developed in previous assignments (or the solutions posted on the ilearn site) as a starting point for this assignment: in effect, each previous assignment will become a subroutine in this one. Build a data type converter that prompts the user to enter one of the following types of input: a) a decimal integer, indicated by the prefix โ#โ, in the range โ32k to +(32k-1); or b) a 2โs complement binary integer, indicated by the prefix โbโ, from 1 to 16 bits; or c) a hexadecimal number, indicated by the prefix โxโ, from 1 to 4 digits. In each case, the number of input digits is not fixed โ i.e. completion of input is indicated by cr/lf (i.e. ASCII char x0A). Also, the decimal number may be prefixed by + or โ signs, but not the hex or binary numbers. OUTPUT: Then, convert the input value to both the other two data types and write them to the console: e.g. given a decimal input # the output will be something like:
#10 = b #10 = x0A or you may choose the format: #10 = b0000 0000 0000 1010 #10 = x000A Note that if the number entered is a decimal negative, you will first convert it to 2โs complement binary, and only then convert the resulting binary to hex: Input: # - Output: **# -1 = b1111 1111 1111 1111
If a negative binary, or its eqivalent hex is input, the conversion to decimal must show both sign and magnitude: Input: xFFFF Output: xFFFF = b1111 1111 1111 1111 xFFFF = # - Use subroutines for all functions โ input, conversion, and output โ so your โmainโ routine will be little more than a sequence of calls to these subroutines. ERROR CHECKING: As in previous assignments, test the input for invalid characters (e.g. letters in a decimal input, letters >F in a hex input, anything other than 0 or 1 in a binary input). For hex numbers, you may choose to restrict input to only upper case letters, or only lower case letters. If an error is detected, output an error message and return to the initial prompt. NOTES:
Grading policy: Possible points: 10 Program assembles without errors: 3 Program runs correctly on LC-3 simulator 5 Well commented code: 2 Assignment submitted without name and SSN: -5 points (if we can figure out who you are!) Assignment submitted to the wrong folder: WONโT BE GRADED!!!!!