

#include <iostream>
#include <vector>
#include <string>
#include <fstream>
using namespace std;
class phone//class that creates objects of converted text
{
public:
string id;
phone() {}
phone(char a)
{
switch (a)
{
case '2':
id = "abc";
break;
case '3':
id = "def";
break;
case '4':
id = "ghi";
break;
case '5':
id = "jkl";
break;
case '6':
id = "mno";
break;
case '7':
id = "pqrs";
break;
case '8':
id = "tuv";
break;
case '9':
id = "wxyz";
break;
default:
id = a;
}
}
~phone() {}
};
vector<string> ans; //final vector of answer
void save()//function to save final text
{
ofstream final("ans.txt");
for (auto it = ans.begin(); it != ans.end(); it++)
{
final << it - ans.begin() + 1 << ". " << *it
<< "\t\t";
if ((it - ans.begin() + 1) % 4 == 0 && (it - ans.begin() +
1) != 0)
final << endl;
}
}
string fact(vector<string> main, int i, string
temp)//recursive function to calculate all possible
combinations
{
if (i == main.size())
{
ans.push_back(temp);
return "";
}
for (int j = 0; j < main[i].length(); j++)
{
fact(main, i + 1, temp + main[i][j]);
}
return "";
}
int main()
{
cout << "Enter Mobile No\t";
string no;
vector<string> temp;//temporary vector of strings to store
decoded text
cin >> no;
for (int i = 0; i < no.length(); i++)
{
char a = no[i];
phone ab(a);//create object
temp.push_back(ab.id);
ab.~phone();//destroy object
}
string g = fact(temp, 0, "");//call recurssive function to
calculate final answer
for (auto it = ans.begin(); it != ans.end(); it++)
{
cout << it - ans.begin() + 1 << ". " << *it
<< "\t\t";//some indentation
if ((it - ans.begin() + 1) % 4 == 0 && (it - ans.begin() +
1) != 0)
cout << endl;
}
save();//call save
}


COMMENT DOWN FOR ANY QUERIES AND,
LEAVE A THUMBS UP IF THIS ANSWER HELPS YOU.
Phone Number Problem (Use Object-Oriented Programming Style. Otherwise there will be no credit) Write a C++ program tha...
Write a C++ program that inputs a single letter and prints out the corresponding digit on the telephone.The letters and digits on a telephone are grouped this way:2 = ABC 4 = GHI 6 = MNO 8 = TUV3 = DEF 5 = JKL 7 = PRS 9 = WXYNo digits correspond to either Q or Z. For these two letters, your program should print a messageindicating that they are not used on a telephone. If a letter in lower...
in C++ Description The purpose of this challenge is to manually manipulate character arrays. This challenge converts text in phone numbers to their equivalent values on a phone keypad. Requirements Write a program to decode phone numbers with letters in them. Create a void function decodetext(char after[], char before[]). This function should be case-insensitive. Do NOT cout in this function. Declare a char array to hold a maximum of 50 characters. Ask the user to enter a string. Use cin.getline(char_variable,...
hello. i need help with number 2
ONLY
1. Use if statements to write a Java program that inputs a single letter and prints out the corresponding digit on the telephone. The letters and digits on a telephone are grouped this way 2=ABC 3 = DEF 4 GHI 5 JKL 6 - MNO 7 - PRS 8 - TUV 9-WXY No digit corresponds to either Qor Z. For these 2 letters your program should print a message indicating that they...
This is Python
The program should accept input from the user as either 7-digit
phone number or 10-digit. If the user enters 7 characters, the
program should automatically add "512" to the beginning of the
phone number as the default area code. Dash (hyphen) characters do
not count in input character count, but must not be random. If the
user enters dashes the total character count must not exceed
12.
The program should not crash if the user enters invalid...
Write a new program (hw6-pr1) meeting at least the following minimum requirements: Opens the text version of this file (hw6-Spring2017.txt) and searches thru the file for the first occurrence of each of the 26 uppercase characters of the alphabet (A-Z), then each the 10 digits (0-9), and finally each of the 26 lowercase characters of the alphabet (a-z). As it finds each of these characters it should also record its position in the file (assume the first character in the...
Regular C Programming
It
is just a random generator of telephone numbers
DESCRIPTION To make telephone numbers easier to remember, some companies use letters to show their telephone number, but mapping the letters to the numbers on a standard telephone keypad: 1 2 ABC 3 DE 4G 5 11 6 MNO 7 PONS 8 Tu 9.xyz # For example, using letters & spaces, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone...
Intro to Programming in C – Large Program 1 – Character/ Number converter Assignment Purpose: To compile, build, and execute an interactive program with a simple loop, conditions, user defined functions and library functions from stdio.h and ctype.h. You will write a program that will convert characters to integers and integers to characters General Requirements • In your program you will change each letter entered by the user to both uppercase AND lowercase– o Use the function toupper in #include...
Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...
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...
Programming Concepts CS 225 for C++ To make telephone numbers easier to remember, some companies use digits and letters (or only letters) to show their telephone number. In some cases, to make a telephone number meaningful, companies might use more than seven digits and letters. Here are some examples: Phone Number in Display Note Actual Phone Number GET LOAN - 438-5626 CALL HOME More than seven digits/letters used for ease of remembrance. 225-5466 111 GOLD - 111-4653 Glass4u - 452-7748...