Purchase Solution

C++ program to convert numbers from one base to another

Not what you're looking for?

Ask Custom Question

Write a C++ program that will convert any base 10 number v to any base b. Input two values, the first is the base 10 number and the second value is the base that the base 10 number v is to be converted to. The base can only be between 2 and 9. Invalid input should be flagged.

Example:
input 175 3
output 175 in base 10 is 20111 in base 3.

The program must use function to convert numbers from one base to another, and it should read its input from a file.

Content (to be used for testing) of attached Word file named as "Base Conversion File.dat":
175 2
175 8
175 5
3 8
98 4
98 7
98 9
256 2
256 8
256 4
111 5
999 6
100 10
60 3
100 1
512 2

Purchase this Solution

Solution Summary

The program reads in pairs of (number in base 10, target base) from input file "Base Conversion File.dat" and writes the number converted to target base, in output file "output.txt". It assumes fair and valid input, that is, the input file contains even count of numbers and all are positive integers.

Solution Preview

Please find attached 371252.cpp that has been tested working with the attached input file. Used input file and ...

Purchase this Solution


Free BrainMass Quizzes
Java loops

This quiz checks your knowledge of for and while loops in Java. For and while loops are essential building blocks for all Java programs. Having a solid understanding of these constructs is critical for success in programming Java.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Basic Networking Questions

This quiz consists of some basic networking questions.

C++ Operators

This quiz tests a student's knowledge about C++ operators.

Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.