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
Which role is responsible for turning the product backlog into incremental pieces of functionality? bookmark this question
Misha Larkins [42]
The answer is the team. Teams are self-establishing which no one not even the scrum master tells the team how to turn product backlog into augmentations of stoppable functionality. Each team member put on his or her knowledge to all of the complications. The interaction that outcomes progresses the entire scrum team’s general competence and usefulness. The optimal size for a scrum team is seven people, plus or minus two. When there are fewer than five team members, there is less interface and as a result less productivity improvement. The product owner and scrum master roles are not comprised in this count. Team arrangement may variation at the end of a sprint. Every time Team membership is altered, the productivity increased from self-organization is reduced.
4 0
3 years ago
Read 2 more answers
Which math ratio represents efficiency?
andrew-mc [135]

Answer:

I think its the second one

6 0
3 years ago
i need help with this my laptop is not let me connet to my wifi and when i try to add out wifi if says "connect Failed" please h
dexar [7]

Answer: try taking it to your media center for help or maybe try connecting to different wifi

Explanation:

7 0
3 years ago
How do you change the username on here?
never [62]

Answer:

I don't think you can. You can try to make an email that has the name you want and use that.

Explanation:

6 0
3 years ago
true or false : The incorrect attitude towards driving is the cause of most collisions among teenage drivers.
natulia [17]
That is true your state of mind is what matters most 

4 0
3 years ago
Read 2 more answers
Other questions:
  • Once you have selected the range of cells for your table data, from which tab can you open the Insert Table dialog box?
    6·2 answers
  • Variables in PHP must begin with what symbol?
    11·1 answer
  • A program that processes data submitted by the user. Allows a Web server to pass control to a software application, based on use
    11·1 answer
  • You cannot advance slides during the slide show by pressing the PAGE DOWN key
    12·1 answer
  • Which of the following actions is most likely to be effective in reducing the digital divide at a local level? A Creating an app
    9·1 answer
  • Identify what a computer needs to
    14·1 answer
  • 17. What are the basic modes of operation of 8255?Write the features of mode 0 in 8255?
    8·1 answer
  • How do you change your name in the profile section because i am trying to change my name.
    9·2 answers
  • Instructions: Write a program that calculates the amount of ingredients needed for various flavors of cheesecake.
    13·1 answer
  • Windows is a GUI Operating System, what is the other type?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!