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.
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?
|