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
11) A single inheritance model means: * A) A class can only have one parent class (superclass) B) A class can only have one chil
ollegr [7]

Answer:

The correct answer is Option A (A class can only have one parent class (superclass))

Explanation:

The inheritance model is a computer program used in Javascript. This model aimed to make code that has been programmed already still relevant to be used again at any time minimizing errors associated with typing a new code. Inheritance  makes the attributes of a particular class valid while still possible to use the attributes of another class.

A child class (subclass) inherits from the parent class (superclass). So, it is a single inheritance once the child class (subclass) inherits from a single parent class (superclass) creating a subclass. A parent class (superclass) is the class that gives its attributes for inheritance.

8 0
3 years ago
You're the administrator for a large bottling company. At the end of each month, you routinely view all logs and look for discre
Natali [406]

Answer:

It seems as though it would be a DDoS attack.

Explanation:

The characteristics are as follows:

A slow down of operations and attempting to get access into said service.

4 0
3 years ago
7) through: (0, 4) and (-1,0)​
Andreyy89

Answer:

its 5

Explanation:

7 0
3 years ago
Fill the validateForm function to check that the phone number contains a number (use the isNaN function) and that the user name
Wittaler [7]

The answer & explanation for this question is given in the attachment below.

8 0
3 years ago
Having just one error on a cover letter may eliminate an applicant from being considered for employment?
Andreas93 [3]

Answer:

Honestly, it depends

Explanation:

As we all know, Artificial Intelligence (AI) is being more and more frequently used to scan through résumé's to automatically check for spelling mistakes, job history and other relevant background information. As part of it's algorithm, AI would automatically bin/discredit applications that include incorrect details.

6 0
3 years ago
Other questions:
  • _______ are special incentives or excitement-building programs that encourage consumers to purchase a particular product, often
    7·1 answer
  • Network address translation is useful because it enables
    5·1 answer
  • Write a function named "list_concat" that takes a list of strings as a parameter and returns the concatenation of all the values
    13·1 answer
  • Name two different ways you can bring up the my computer folder
    9·2 answers
  • While working with style formatting for a Microsoft Word document, when you change the text or paragraph formatting of a single
    13·1 answer
  • Write a VB program to convert a temperature from Celsius to Fahrenheit and vice versa.
    15·1 answer
  • Define computer ?what is water pollution?<br><br><br>​
    15·1 answer
  • Historically, storytelling passed down the most important ideas about life, family, and society from generation to generation; t
    10·2 answers
  • Question # 2 Multiple Select You wrote a program to compare the portion of drivers who were on the phone. Which statements are t
    6·1 answer
  • 5.5 Learning Objective: To demonstrate that the student understands the definition of Big O. To demonstrate that the student und
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!