Telephone number code - Please assist

+2 brenton leon · February 22, 2015
Program that reads a list of telephone numbers expressed in capital letters from a text file and converts the telephone numbers in capital letters, to the corresponding telephone numbers in digits.


creates another file in which the telephone numbers appear in digital format, one number per line. Allow the user to specify the name of the input file, as well as the name of the output file.

Apply the following convention: If a number consists of more than seven letters, only the first seven letters are processed. A space is displayed between the third and fourth digits. Letters A, B and C corresponds to digit 2; letters D, E and F to digit 3; letters G, H and I to digit 4; letters J, K and L to digit 5; letters M, N and O to digit 6; letters P, Q R and S to digit 7; letters T, U and V to digit 8; and letters W, X, Y and Z to digit 9.

Post a Reply

Replies

Oldest  Newest  Rating
0 Dol Lod · February 23, 2015
You haven't exactly asked a question ... If you want an answer you have to have a question. 
0 brenton leon · February 23, 2015
Hi Arjun

the question is to create a program that reads a list of telephone numbers expressed in capital letters from a text file and converts the telephone numbers in capital letters, to the corresponding telephone numbers in digits.
0 brenton leon · February 23, 2015
Linguist Lama .. t\thats is harsh !!!.... here is my code for reading 20 numbers from a Text file and printing onto screen ...

its does not write to a file though? 

#include <iostream>
//#include <string>
#include <fstream>
using namespace std;
int main()
{
    int sum =0;
    int x;
    char fileName[20];
    ifstream numbersFile;
    ofstream SortedFile;
    cout << "type file number: " ;
    cin.getline(fileName, 20);
    numbersFile.open(fileName);

    if(!numbersFile.is_open())
    {
        cout<<"It failed" << endl;
        return 0;
    }
    while (numbersFile>> x)
    {
         cout << x << "   " <<endl ;
    }
    if(SortedFile.fail())
    {
        cout<<"Error opening writing to file" << endl;
        return 0;
    }
    SortedFile << x << endl;
    cout << x << endl;
    numbersFile.close();
    return 0;
}
0 brenton leon · February 23, 2015
Above is try to read integers from file , sort lowest to highest in array and write to file ... this is all new to me but thanks to Bucky's vid's and some reading ... i'm getting there
0 brenton leon · February 23, 2015
code using array .... somehow reads 20 integers from Numbers.dat file but does not write to files?????

#include <iostream>
#include <string>
#include <fstream>
   using namespace std;
int main()
{

    ifstream file("Number.dat");
     if(file.is_open())
    {
        string myArray[20];

        for(int i = 0; i < 20; ++i)
        {
            file >> myArray;
            cout << myArray << " " << endl;
        }
    }

}
  • 1

C++

106,985 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator