C++
Function name: getLocalPhone

Code
#include<iostream>
#include<string>
using namespace std;
string getLocalPhone(string num)
{
string str="";
if(num.substr(0,2)=="+1")
{
str="("+num.substr(2,3)+")-"+num.substr(5,3)+"-"+num.substr(8);
}
if(num.substr(0,3)=="+33")
{
str="0"+num.substr(3,1)+"
"+num.substr(4,2)+" "+num.substr(6,2)+" "+num.substr(8,2)+"
"+num.substr(10);
}
if(num.substr(0,4)=="+852")
{
str=num.substr(4,4)+"
"+num.substr(8);
}
return str;
}
int main()
{
cout<<"+12062812000
-->"<<getLocalPhone("+12062812000")<<endl<<endl;
cout<<"+33140205990
-->"<<getLocalPhone("+33140205990")<<endl<<endl;
cout<<"+85223677065
-->"<<getLocalPhone("+85223677065")<<endl<<endl;
return 0;
}
output
If you have any query
regarding the code please ask me in the comment i am here for help
you. Please do not direct thumbs down just ask if you have any
query. And if you like my work then please appreciates with up
vote. Thank You.
6 Formatting getLocalPhone * Takes one string parameter (phone number) Returns a formatted local ...
I need help with this assignment in C++,
please!
*** The instructions and programming style details
are crucial for this assignment!
Goal: Your assignment is to write a C+ program to read in a list of phone call records from a file, and output them in a more user-friendly format to the standard output (cout). In so doing, you will practice using the ifstream class, I'O manipulators, and the string class. File format: Here is an example of a file...
Write a python function score_formatter() that takes one parameter, which is a formatted string that contains information about the score received by a student in a particular subject. The function analyzes the string and returns a reformatted string for the score. You will need to use the function re.sub that is discussed in the lecture notes. If the string does not match the pattern, the function returns the string "error". The input string is always given in the format specified...
c++ Write a function Count_m_z that takes a string as an input parameter argument and counts the number of m, n, o, ... z characters in it. The function returns an integer value for the number of times those 14 lowercase letters appear in the input string. Your function should be named Count_m_z Your function should take one string parameter Your function should return the number of m, n, o, ... z characters as an integer Your function should not...
Write a function count_vowels(s) that takes a string as an argument and returns the number of vowels ('a', 'e', 'i' 'o', 'u') in the string. Should you use a for or while loop? (Implement this as a function, not as a class with a method.) Be sure to include unittest test cases to demonstrate that your code works properly, e.g Part 2: last_occurance(target, sequence) Write a function last_occurance(target, sequence) that takes two arguments: 1. target: A target item to find...
Supposing we are all celebrities who care about our privacy as much as our programming course grades....we hope our email address and cell phone number are masked if we type them online. Now you need to write a python/java code to realize this masking function. Requirement: (1) Assuming the input email address is in the format of "name1@name2.name3", all names must be converted to lowercase and all letters between the first and last letter of the name1 must be replaced...
Qhuestion 6 i.Write a recursive function reverseConcatenate that takes as input a list with string entries and returns one long string which is the concatenation of all the string entries in reverse order. For instance, reverseConcatenate([’how’, ’are’, ’you?’]) should return ’you?arehow’.
The function below takes one non-negative numeric parameter: (credit_hours_earned) containing the number of credit hours that a student earned. Complete the function to return a string indicating the student's classification as indicated by the table below. For example, for 36 credit hours, your function should return 'Sophomore standing'. (python) Freshman standing = 0–29.9 hours Sophomore standing = 30–59.9 hours Junior standing = 60–89.9 hours Senior standing = 90 or more hours Function: def determine_standing(credit_hours_earned):
Exercise 4 – Printing out 10 multiples per row Design a function called print_ten_multiples that takes an integer as a parameter. The function should print out the first 10 multiples of all numbers from 1 up to the given number. The values printed should be formatted with "3d". Example: print(format(x, "3d")) Examples of how the function output should look with this formatting: print_ten_multiples(3): 1 2 3 4 5 6 7 8 9 10 2 4 6 8 10 12 14...
(IN JAVA) Write a program named Review.java and implement the following methods: public static boolean isValidTicTacToeBoardString(String str) This method takes as its parameter a String that contains 9 characters representing the status of the Tic Tact Toe game. The String is mixed with X, O, x, o, and other letters. The first three letters represent the first row, letter 4 through letter 6 represent the second row, and the rest for the last row. To be considered as a valid...
Python 3 Create a function that takes an array and an integer v, and returns the number of v occurrences in the array. Add a variable Nsteps to count how many times the loops have executed and display that information in a message The main program must take an array / list 2D, call the function, and display the result. >>>l3 = [52, 14, 14, 8, 85, 69, 1, 77, 94, 96, 51, 65, 35, 32, 87, 92, 74, 47,...