View the step-by-step solution to:

Project 4 For project 4, you will write a program that will convert a base 10 integer into a different base (base 2 = binary, base 8 = octal, or base...

Can you help me with a project.

Here is my email. @[email protected]

Below is the project.

Project 4 For project 4, you will write a program that will convert a base 10 integer into a different base (base 2 = binary, base 8 = octal, or base 16 = hexadecimal). First, prompt the user for an unsigned integer (i.e. not negative) and only proceed if you get such a number (you can assume the user will enter an integer). Next prompt for the new base (b or B for binary, o or O for octal, h or H for hexadecimal) and only proceed if you get a valid letter. Depending on the user’s choice, do the base conversion and display the result in an alert box. After showing the user the result, prompt for them to enter “s” or “S” to stop. Any other string would repeat the entire process. After the user enters “s” or “S” to stop, show the user in an alert box what the smallest and largest valid number was that they had entered while the program was running. Question: How do I convert a base 10 integer to base n ? Answer: Divide the number by base n (each time updating the value of the number to be the quotient from the last division), until you get a quotient of zero. Keep track of the remainders. The remainders collected from bottom up (not top down) will be the answer in base n . Example: What is 108 in base 2? 108 10 = ? 2 108 / 2 = 54 R 0 54 / 2 = 27 R 0 27 / 2 = 13 R 1 13 / 2 = 6 R 1 6 / 2 = 3 R 0 3 / 2 = 1 R 1 1 / 2 = 0 R 1 The answer is 1101100 (notice the answer is not 0011011)
Background image of page 1
A base 2 number will only have digits 0 and 1. A base 8 number will have digits 0 to 7. A base 16 number needs “digits” 0 to 15. Since we don’t have a unique symbol for 10 to 15, we use A for 10, B for 11, C for 12, D for 13, E for 14, and F for 15. All the logic that does the conversion needs to be written by you. If you use any type of built-in function/method that is designed to convert a number in one base and return it in another base, you will get very little to no credit on this assignment. For example: var a=255; alert(a.toString(16)); //will display ff which is 255 in base 16 would not be allowed because JavaScript does the conversion for you. You have to write the logic that does the conversion. Also, all the logic that figures out the smallest/largest number has to be written by you. If you use any type of built-in function/method that is designed to take in numbers and return the smallest or largest, you will get very little to no credit on this assignment. For example: alert(Math.min(75,25,32,22,105)); //will display 22 which the smallest number would not be allowed because JavaScript does the work for you. You have to write the logic that figures out the smallest and largest values. Another example of what would not be acceptable is to use the built- in sort method and return the first elements (min) or the last element(max) Finally, you cannot use the array method reverse (e.g. myArray.reverse( )). If you need to reverse the order of the numbers in an array, you need to write the logic yourself. You can make this one of your required function (see below for details). You are allowed to use array method that work with one value at a time like push , pop , shift , and unshift . Your program has to be broken up into functions. Remember, a function is a unit of code that is designed to perform a specific task. You can unit test your function (test in isolation) and make sure they work before using them as building blocks in your program. You have to implement the following functions:
Background image of page 2
Show entire document
Sign up to view the entire interaction

Top Answer

Hey, Please find attached. If... View the full answer

Project4.zip - Preview not available

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online