Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2.19 **zyLab: Convert Binary to Decimal Convert Binary to Decimal Computers use binary numbers all the time. For example, they store integers as binary in
2.19 **zyLab: Convert Binary to Decimal Convert Binary to Decimal Computers use binary numbers all the time. For example, they store integers as binary in memory, but when we print those integer variables, we see the decimal representation. In this zyLab, you will write a small program to convert binary numbers with 5 digits to their decimal representation. Since we know there will always be 5 digits, we can generalize an equation to calculate the decimal number: 24 (first bit, most significant) +23 (second bit) +22( third bit) +21 (fourth bit) +20 (fifth bit) Given 5 binary bits, we want your program to output the decimal representation. You will need to complete to primary steps: 1. Take in the 5 inputs 2. Complete the calculation to convert the binary input to a decimal output For example, given input: 01011 Where the first bit inputted is the most significant, our output should be: 11 Hints: - You can assume there will always be 5 numbers (bits) inputted which will be either 0 or 1 - Make sure you're matching up your inputs correctly (both name and type) - Use methods from the java.lang.Math class to complete the calculation - Remember what Math.pow returns (revisiting Type Conversions could be helpful) Created by: Axel and Haris \begin{tabular}{l|l} LAB & 2.19.1: **zyLab: Convert Binary to Decimal \\ ACTIVITY & \end{tabular} 0/10 Main.java Load default template
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started