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 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 "[email protected]", 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’.
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...
1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...
Write a method called printReverse() that
takes a string and uses recursion to print the contents of the
string in reverse order. The string itself should
not be reversed; it must be left in its
original form.
The method has the following header:
void printReverse(String s, int i)
where s is a reference to the string, and i is an integer
parameter that you may use as you see fit. You do not need
to code up this method as...
phones saturated animal deaths 124 33 8 81 49 31 6 55 181 38 8 80 4 17 2 24 22 20 4 78 152 39 6 52 75 30 7 88 54 29 7 45 43 35 6 50 41 31 5 69 17 23 4 66 22 21 3 45 16 8 3 24 10 23 3 43 63 37 6 38 170 40 8 72 125 38 6 41 12 25 4 38 221 39 7 52...
Objective In this assignment, you will practice solving a problem using object-oriented programming and specifically, you will use the concept of object aggregation (i.e., has-a relationship between objects). You will implement a Java application, called MovieApplication that could be used in the movie industry. You are asked to implement three classes: Movie, Distributor, and MovieDriver. Each of these classes is described below. Problem Description The Movie class represents a movie and has the following attributes: name (of type String), directorName...
Java Project Requirements: Account class Superclass Instance variables clearPassword String Must be at least 8 characters long encryptedPassword : String key int Must be between 1 and 10(inclusive) accountId - A unique integer that identifies each account nextIDNum – a static int that starts at 1000 and is used to generate the accountID no other instance variables needed. Default constructor – set all instance variables to a default value. Parameterized constructor Takes in clearPassword, key. Calls encrypt method to create...