1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
#include<bits/stdc++.h>
using namespace std;
//Using the bool statement let user re-enter phone number
bool Vaild_areacode(const string&phone_length)
{
//Correct area code for xyz company
const string areaCode[] = {"520", "620","405", "550", "650"};
//If statement for enter phone number to check the user enter number is 10 digit number
if (phone_length.length()!=10 || phone_length.length()<10)
{
//If the the not equal 10 digit number ot less than 10 digit number will print"Invalid phone number"
cout << "Invalid phone number ;"<<endl;
return false;
}
//only focus first tree numbers to identify it is in right area code
string area_C = phone_length.substr(0, 3);
//Use the find function to check if the code is valid
if (find(begin(areaCode), end(areaCode), area_C) == end(areaCode))
{
//If user put in wrong area code it will print "!!ERROR!! ,Wrong area code or Invalid phone Number ! "
cout << "( !!ERROR!! ,Wrong area code or Invalid phone Number ! ) \n ";
return false;
}
//Util user put in right phone number program will print"The phone number is valid"
cout << "The phone number is valid" << endl;
return true;
}
int main()
{
//Let user enter phone number
cout<<"Enter the your phone number: ";
string get_phone_number;
//Using the loop statemnt let keep forever if enter value is not valid
while(true)
{
//let user enter phone number
cin >> get_phone_number;
if (Vaild_areacode(get_phone_number))
//Break out of loop
break;
//Displayed what is wrong
cout << "Please re-enter your phone number" << endl;
}
//exit the program
return 0;
}
|
In this project, you will write a program that simulates telephone service provided by a switch at the central office of area code 405. The switch receives a call from cell 405 and generates billing information based on how long the call has lasted, namely, call connection time.
the project is about when the user you program will
generate a call by prompting user input for destination phone numberl . Once getting a destination phone number,
a call connection time must be generated by using a random number generator. Based on the call connection time, service fee will be calculated in the following way: If a call is requested to a destination phone number with the same area code of 405, which is called a local call, the service rate is 2 cents per mins.
Let us call this service rate the basic rate. If a call request is long-distance, i.e. to other area code, the service rate depends on the distance between the 405 cell and the destination cell. If these two cells are adjacent, the service rate is 1.25 times the basic rate. If the two cells are one-cell apart, the service rate is 1.75 times the basic rate. Table 1 shows an example of service rates according to the destination number of a call request.
this is what I got so far,
I don't know how to add the idea of Call Connection Time
the question is: Once you validate an input, generate call connection time by using a random number generator. Now, to be more realistic on call connection time, we want to restrict its value to the set of minutes, {1, 2, 3, ... , 180}. Define the following function to get a call connection time
unsinged char get_call_time();
also I need to add Compute Service Charge
the question is: Once a call is terminated, compute the service charge based on the rates shown in Table. To do so, define the following function
table:
Destination number Service rate
4055547788 2 cents per min (basic rate)
5204341234 1.25 * basic rate
6201234567 1.75 * basic rate
double get_service_charge(unsigned long);