1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Butoxors [25]
4 years ago
11

Write a program that reads a 4-bit binary number from the keyboard as a string and then converts it into decimal. For example, i

f the input is 1100, the output should be 12. (Hint: Break the string into substrings and then convert each substring to a value for a single bit. If the bits are b0, b1, b2, and b3, the decimal equivalent is 8b0+ 4b1+ 2b2+ b3.)
Computers and Technology
1 answer:
adell [148]4 years ago
7 0

Answer:

import java.util.Scanner;

public class ss11{

       public static void main (String[]args) {

             Scanner keyboard = new Scanner (System.in)

             String a1, a2, a3, a4, a5;

              int i1, i2, i3, i4, i5;

              System.out.println("Enter a four bit binary number:");

               a1= keyboard.next();

               a2= a1.substring(0,1);

               a3= a1.substring(1,2);

               a4= a1.substring(2,3);

               a5= a1.substring(3,4);

                i1 = Integer.parseInt(a2);

                i2 = Integer.parseInt(a3);

                i3 = Integer.parseInt(a4);

                i4 = Integer.parseInt(a5);

                i1= i1 * 8;

                i2= i1 * 4;

                i3= i1 * 2;

                i4= i1 * 1;

                i5= i1+i2+i3+i4;

                System.out.println("The converted decimal number is: +i5);

}

}

Explanation:

You might be interested in
You can easily merge files even if each file contains a different record layout. Group of answer choices True False
pychu [463]

Answer:

true!! i may be wrong tho

Explanation:

7 0
3 years ago
The concept of "space" on a computer usually refers to the___.​
vesna_86 [32]

Answer:

Option "A" is the correct answer to the following question.

Explanation:

Word 'Space' use for total storage available in hard drive.

Free storage in the hard drive is commonly called space, space is an empty place similarly free or empty space in a hard drive called "Space".

Usually, the term space is used for the empty place, so we can say that the appropriate choice is correct.

4 0
3 years ago
False when you tap or click the ‘decrease font size’ button, excel assigns the next lowest font size in the font size gallery to
castortr0y [4]
That is actually true. In order to format the font, margins and alignment of a form you need to s<span>elect the control that you want to format, then right-click the selection, and then click Format Control. What you do next is that on the Font tab you select the font type, font style, font size, other formatting options for the selected text and in order to finish to press ok </span>
6 0
3 years ago
In the past, workers would usually complete ______. a. A variety of tasks on a daily basis b. The same tasks every day c. Thinki
yKpoI14uk [10]

Answer:

B

Explanation:

did it on edge

5 0
3 years ago
Read 2 more answers
Setting the isShowing property to false of the opacity property to o will delete an object from an Alice world.
Tema [17]
I think true I’m not for sure
5 0
3 years ago
Read 2 more answers
Other questions:
  • What are the two different frequencies WiFi operates on?
    9·2 answers
  • Properly defined the primary part of a CPU​
    5·1 answer
  • An email message form includes all of the following main areas except
    11·2 answers
  • What are some good websites i can use to test my knowledge?
    11·2 answers
  • Write a program that inputs a time from the console. The time should be in the format "HH:MM AM" or "HH:MM PM". Hours may be one
    6·1 answer
  • Which of the following JavaScript expressions is equivalent to the given HTML code? ​ a. Document.getelementbyId("menu1").menu=
    6·1 answer
  • The physical part or components of a computer system called​
    5·2 answers
  • 10010 - 1011 binary subtraction​
    5·1 answer
  • In the table below, identify the data type that would be most suitable for the second field.
    10·2 answers
  • 2. The Warren Commission investigated the assassination of President _______________________ in 1964.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!