Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribedimage text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

To solve p + 3q = 5z + tan( y - 3x)

Answered: 1 week ago