Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C++ that, given a seven-digit number, writes to a file every possible seven-letter corresponding to that number. There are 2187 (3

Write a program in C++ that, given a seven-digit number, writes to a file every possible seven-letter corresponding to that number. There are 2187 (3 to the seventh power) such words.

Include the numbers 0 and 1; just embed them in the words as a 0 and a 1. Example: one possibility for 5701679 would be: LR01OPW. Assume the user correctly enters only 7 digits (no -). Read the user input into a char array. Use a recursive function to build the combinations. Leave the output in a file and inform the user of the file name before exiting.

You will need some constants:

const int ROWSIZE = 10;

const int COLSIZE = 5;

const int NUMSIZE = 8;

You will need an array to read in the users 7-digit number, a 2-dimensional character array, and an array in which to build the number combinations:char array[NUMSIZE]; // user input do not go beyond 7 chars and a null byte!

// 2-d array of letters

char letters[ROWSIZE][COLSIZE] = { { '0', '\0', '\0', '\0', '\0' },

{ '1', '\0', '\0', '\0', '\0' },

{ 'A', 'B', 'C', '\0', '\0' },

{ 'D', 'E', 'F', '\0', '\0' },

{ 'G', 'H', 'I', '\0', '\0' },

{ 'J', 'K', 'L', '\0', '\0' },

{ 'M', 'N', 'O', '\0', '\0' },

{ 'P', 'Q', 'R', 'S', '\0' },

{ 'T', 'U', 'V', '\0', '\0' },

{ 'W', 'X', 'Y', 'Z', '\0' } };

char buildArr[ROWSIZE]; // output

Your recursive routine should have five parameters:

void combine (char *, // user input array

char [ROWSIZE][COLSIZE], // 2-d array of letters

char *, // array in which to build the output

int, // index into output array

ofstream&); // reference to the open output file

Please include comments

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

0137916787, 978-0137916788

More Books

Students also viewed these Databases questions