Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9207414

Have any Question?


Related Questions in Computer Engineering

Software engineering software architecture questioncan

(Software engineering (Software Architecture) question) Can someone explain how a system's decomposition into components is driven by the system's features/requirements. Also, how can this decomposition be used to determ ...

There are several different vdi technologies and many

There are several different VDI technologies and many different VDI providers. For this discussion select, one VDI software provider offering a Centralized VDI approach and another provider offering Hosted VDI. Compare t ...

The scenario is to create a program for a windows company

The scenario is to create a program for a windows company. The program should display the total amount a customer owes, given the number of windows ordered and the price per window. Total owed is calculated by multiplyin ...

Question suppose that in addition to edge capacities a flow

Question : Suppose that, in addition to edge capacities, a flow network has vertex capacities. That is each vertex v has a limit l(v) on how much flow can pass through v. Show how to transform a flow network G = (V, E) w ...

Simcon is a forensics software tool that can generate

SIMcon is a forensics software tool that can generate information for mobile device investigations. In Hands-On Project 12-1, you examined SMS messages on two phones that had been generated by SIMcon. In this project, yo ...

When is a subclass a subclasswhen programming or solving

When is a Subclass a Subclass When programming, or solving any sort of problem for that matter, abstraction plays a key role in the decision-making process. It allows you to remove irrelevant details in order to understa ...

Serializationdesign a verilog module to convert a 64-bit

Serialization Design a Verilog module to convert a 64-bit data signal with periodic timing (eight-cycle period) into a series of eight-bit signals with periodic timing (one-cycle period). You must store the input data, a ...

Assume that todayis your 25thnbspbirthday and have an

Assume that todayis your 25th birthday and have an annual salary of $60,000 (+ super). Your salary is expected to grow by 3% per year before reaching retirement age (your 65th birthday). You are currently doing some rese ...

Requirementsthis week you will write single page web

Requirements This week you will write single page web application that will receive incoming POST and GET requests. If it is a POST request it should say at the top of the page, in an H1 tag "POST Request Received". If a ...

Question need a discussion post of 500-700 words in apa

Question: Need a discussion post of 500-700 words in APA format with 4 references & citations. Only For Dr. Silvercoast Which of these principles can you apply at your workplace? Select one or two and provide examples. O ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As