Program program that converts eight (8) bit binary numbers

Assignment Help Computer Engineering
Reference no: EM1332044

Write a C++ program that converts eight (8) bit binary numbers to their decimal equivalents. The program should retrieve the binary numbers (one at a time) from a data file (use a long int for the variable that represents the binary number).

For each binary number, convert the number to decimal one bit at a time (or all at once depending on your algorithm). The program will read the binary number (eight binary digits on one line with no spaces between them), convert the number, then go back to the data file to retrieve the next number. The number will have leading 0's if the binary number is smaller than eight digits. For example, the binary number could be 00001100 which would make the result decimal number 12. Or the number could be 10000001 and would result in decimal number 129. Note that the first example number had leading 0's.

The name of the input data file should be "binary.dat". For testing purposes, you will need to create this file and add some valid (and invalid, if any) binary numbers using the criteria described below.

For 5 extra credit points, you should make sure that the binary number only has 0's or 1's and your program should go on to the next number if not. However, you can always assume that the user will always enter eight digits (no more, no less.)

This program could have multiple solutions. The conversion of binary numbers to decimal numbers will be explained in class. However, you can look up conversions on the Internet for more examples. You may (although it isn't the only solution) need to use a combination of the modulus and division operators. It is advisable to plan out the solution to this problem well in advance of coding the program.

You will need to use a for() loop to process the eight bits. You will need to use a while() loop to access the numbers in the data file (checking for the end of file). This program will help you read data from a data file, valid the data and process correct numbers.

Reference no: EM1332044

Questions Cloud

Private-sector making public commitment to diversity : Is it necessary for a private-sector organization to make a public commitment to diversity?
Explain cost of capital of amazon : Explain cost of capital of amazon
Answer the following : What is final value of y after executing the following code.
Factors that affect hrm : Factors that affect HRM - Besides cultural differences, what other factors affect HRM in an organization with international operations?
Program program that converts eight (8) bit binary numbers : Write down a C++ program that converts eight (8) bit binary numbers to their decimal equivalents. The program should retrieve the binary numbers (one at a time) from a data file (use a long int for the variable that represents the binary number).
Analyze three functional areas : Prepare a written recommendation that holistically addresses a problem or business need: Analyze three functional areas
Explaining inclusive environment : What is meant by an "inclusive environment"? Provide examples.
Explain ebusiness strategy : What do you meant by ebusiness and explain ebusiness strategy with example
Make use of a group box to enclose the radio buttons : You have been hired by an engineering company to develop software to perform advanced geometric calculation. Your new boss asked you to develop an application that allows engineers to calculate the surface area and the volume of a sphere.

Reviews

Write a Review

Computer Engineering Questions & Answers

  How personal data can be an overwhelming task

If we are not able to protect our data, and data protection is left to the market, will data protection be possible only for the rich.

  Write down a program that inserts 25 random integers

Write down a program that inserts 25 random integers from 0 to 100 in order into a linked-line object. The problem must calculate the sum of the elements and the floating-point average of the elements.

  Assume that veclist is a vector container

Suppose that vecList is a vector container and vecList = {12, 16, 8, 23, 40, 6, 18, 9, 75} Show vecList after the following statement executes.

  A java application that can hold five doubles in a array

Write down a Java application that can hold five doubles in an array, and display the doubles from first to last, and then display the doubles from last to first. Use the following logic for BubbleSort to sort and display the array in sequence.

  Studying the properties of a network

Studying the properties of a network

  Demonstrate how this search would go

assume an algorithm that processes a data set of size 8 has a runtime of 72, and the same algorithm on a data set of size 20 has a runtime of 420. Using big-O notation, state runtime for this algorithm for the general case of a data set of size n.

  Assume that we are looking in a programming language

suppose that we are looking in a programming language that allows underscore (_) in variable names. When a scanner sees a character string such as AB_CD, is it more likely to identify this string as the single five-character token AB_CD or as thre..

  Advantages and disadvantages to using cots

What are the advantages and disadvantages to using COTS (Commercial Off-the-Shelf) software versus writing your own software within a company environment? Give some examples of problems you have had.

  Describe the steps to complete the list

Promotion time is coming around the corner. In the last board meeting, your supervisor has asked someone to make a list of tables for a Fernandos Skate Shop customer orders.

  Why throw and handle an appropriate exception

Write down a C++ program that prompts the user to enter a length in feet and inches and outputs the equivalent length in centimeters. If the user enters a negative number or a non-digit number, throw and handle an appropriate exception and prompt ..

  Recognizing the error in code

Suppose that the variable A is an arrays of ints. Take the following code segment:Boolean flag = false;

  Give an evaluation of whether the language met its goal

A short history of the language, including which languages it may have been based on and that languages it may have subsequently influenced. This may be part of the introduction or the background.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd