The conversion of binary numbers to decimal numbers

Assignment Help C/C++ Programming
Reference no: EM13938195

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: EM13938195

Questions Cloud

Social capital support innovation : How can social media such as LinkedIn, Facebook and Twitter be used to improe knowledge sharing build social capital support innovation and aid problem solving in one of the following organisational contexts-
How would the deposit be reported in the financial statement : Prepare the entry by Billy Pilgrim to record the delivery of 125 units during 2012. How would the deposit be reported in the financial statements at the end of 2012?
Average mass of the ramp and passengers : The ramp shown below is used to assist passengers boarding light commuter aircrafts. The average mass of the ramp and passengers is 800 kg with the center of mass located at point G. As the ramp angle θ increases, the hydraulic cylinder extends bu..
Fixed price incentive (fpi) contract : The seller has agreed to a fixed price incentive (FPI) contract. The target cost is $450,000 and the target fee is 10% of the target cost. The price ceiling is $540,000 and the buyer/seller share ratio 80/20. The final actual cost is $430,000. Det..
The conversion of binary numbers to decimal numbers : 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 proce..
Prepare the entry to record the payment of warranty claims : What is the December 31, 2009, balance in the estimated warranty liability account? Compute the warranty expense for 2009. Prepare the entry to record the payment of the 2009 warranty claims.
Damon gain organisational knowledge : A mentor has certain functions in an organisation. Identify the types of support offered by this mentor. What else could the mentor have done to help Damon gain organisational knowledge?
Country that have five components : compare three countries, how are they different and what's that means? based on this website. And write 300 words about their difference report.
How do characteristic change after embryonic stage of growth : Discuss the characteristics that define humans as belonging to the phylum Chordata. How do these characteristics change after the embryonic stage of growth?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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