Question: In c + + please . Write a program that converts values using decimal and binary prefixes. Historically, computer professionals have used the SI prefixes

In c++ please . Write a program that converts values using decimal and binary prefixes. Historically, computer
professionals have used the SI prefixes kilo, mega, giga, etc. to mean multiples of 210 instead of the usual
103 : a kilobyte (KB) is 1024 bytes, a megabyte (MB) is (10241024) bytes, etc. This was convenient since
computer professionals generally work in powers of two, and 1024 is "close enough" to 1000. In
computing, the meaning of KB,MB, etc. is not always based on multiples of 210. Disk and solid-state drive
manufacturers assume that a KB is 1000 bytes, a MB is (10001000) bytes, and so forth. Therefore,
today's drive capacities are measured in GB (109 bytes) or TB (1012 bytes). Computer hardware engineers
and software developers still generally refer to powers of two when sizing memory. As the values
represented by the prefixes get larger, so does the divergence between the binary and decimal
meanings of the prefixes. The prefixes are as follows:
By using the binary prefixes from above and reserving K, M, G, etc. for decimal multiples, it is possible
to clearly state what is intended when discussing storage or network needs.
Input from the keyboard value requests in bytes. The line of input will contain three values
separated from each other by single spaces: a positive numeric value which may include a decimal point,
the unit for that value, and the desired unit that the value is to be expressed in. The units will be one of
[KB, MB, GB, TB, KiB, MiB, GiB, TiB]. Assume all conversion requests will be less than 250 bytes.
Output to the screen the result on a separate line. Round the result to three decimal places after the
decimal point and print without leading zeroes or spaces. This result is followed by a single space and
the abbreviation for the desired unit without trailing whitespace. Finally, the program should ask if the
user wants to run the program again (Check case). Refer to the sample output below.
Sample Run:
Enter values: 4 TB MiB
Result: 3814697.266 MiB
Run Again (YN : y
Enter values: 0.5 GB MiB
Result: 476.837 MiB
Run Again (YN): N
In c + + please . Write a program that converts

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!