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]
3 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]3 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
The visitor's age is stored in the variable age, the day of the week is stored in a variable day, and the price in dollars is st
Hoochie [10]

Answer:

If a museum charges different prices based on the day of the week and age of the visitor. The pricing rules are shown below.

- On Tuesday and Thursday children 10 and under get in free ($ 0).

- For all other days and ages the cost is ten dollars ($ 10).

The code in python is;

if (day == 'Tuesday' or day == 'Thursday') and age <= 10:

   price = 0

else:

   price = 10

Explanation:

The logic of the algorithm suggests that that the conditional if-statement assigns zero to the price variable if the day variable is either Tuesday or Thursday and the child's age is 10 or below but assigns 10 to the price variable if the condition is not met.

4 0
3 years ago
The Cisco IOS automatically modifies the dead interval when the _____ interval is changed. (Points : 2) hello
erma4kov [3.2K]

Answer: MD5

Explanation:

 The Cisco IOS modifying the dead internal automatically when the message digest 5 (MD5) internal are changed in the system. When we enabled the MD5 authentication in the Cisco by using the keyword "Message digest" then we configuring the password in the IP OSPF interface command which is known as MD5 key.

The OSPF interface is a compatible configuration in the remote interface before they considered as neighbors in the Cisco system. The MD5 are basically created by the cisco NX-OS.

5 0
3 years ago
Identify a true statement about heuristics: a. They are more complicated than algorithms. b. Unlike algorithms, they do not perm
STatiana [176]

Answer:

The appropriate alternative is Option d.

Explanation:

  • Heuristic also seems to be essentially a methodology that solves numerous major issues in an even cheaper manner. It requires less effort than those of the traditional techniques. It's providing accurate solutions. It has a broader potential in the treatment of computer engineering. It is already being shown in quantum computing.
  • Mathematical implementations also contribute significantly to heuristics. This could make concessions on the component of optimal performance. It can also make concessions on the degree of consistency. It helps to achieve international headquarters at quite a quicker speed.

The latter decisions made are not connected to the conditions. So the above comment is correct.

4 0
3 years ago
____ steganography places data from the secret file into the host file without displaying the secret data when you view the host
EastWind [94]

Answer: Insertion steganography

Explanation: Insertion steganography is the way of encrypting the data with the help of a regular files and message. It is encrypted by the ordinary files because the identification of files can be neglected. This process is carried out just for the protection purpose in extra form and gets decrypted  in the destination port .It has the working based on the replacement of the bits in a file .

8 0
3 years ago
Late at night, some traffic signals change patterns and become _____.
SCORPION-xisa [38]
The answer is B.

Late at night, some traffic signals change patterns and become flashing yellow or red lights.
4 0
3 years ago
Read 2 more answers
Other questions:
  • Hydropower uses moving water to do work, such as grinding grains in a mill. True False
    7·1 answer
  • Your company runs several databases on a single MySQL instance. They need to take backups of a specific database at regular inte
    12·1 answer
  • What is a GUI?
    11·1 answer
  • The flynn effect best illustrates that the process of intelligence testing requires up-to-date ________
    14·1 answer
  • Within a major students can choose to study a specific area within major. For example a journalism student may study military jo
    8·1 answer
  • Davingould1115...................answer 2​
    11·2 answers
  • What is connected to the base unit in Desktop PC?
    14·1 answer
  • Which important aspect of the Roman Empire did the barbarians destroy?
    14·2 answers
  • EDI, ________, smart cards, and digital certificates are designed to support safe and secure online transactions.
    8·1 answer
  • put together a shopping list of items that a first responder should always have at immediate disposal in a field kit. Using curr
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!