Friday, June 12, 2009

The Program Cost Telephone Conversations

Suppose a small shop in the caller telecommunication start a conversation on the clock at the start and finish at the end of time (00:00:00 - 23:59:59). For example 1 credit = 1 seconds, and cost 5 Rupiah per pulse for local conversation and Rp 30 for long distance conversation. This program will only accept entries form the beginning and end of the call. While output a long conversation, and the cost should be paid the callers.

1.Run application, users are prompted to enter the initial call and the end time to call:

"Enter the time now (early): ...................."

"Enter the time now (the end): ..................."

2.After there are two options menu conversation:

a. Local

b. Long

3.Program will show

Talk time: ..........................

Cost of phone: ....................

- For a local option application will calculate the cost of 5 Rupiah / second

- For long distance applications the option to calculate 30 Rupiah / second

There is “ Class Jam ” attribute a, b, c, d, e, f, g, h, i, j, jum1, jum2, jum3 with integer data type and input the data type char. Cost Method biaya with attributes jumlah dan bea.

class jam
{
public:
jam(int x,int y,int z, int k, int l,int m);
void biaya(int jumlah,int bea);
private :
int a,b,c,d,e,f,g,h,i,j;
int jum1,jum2, jum3;

char input;
};

Constructor used to write down the clock input to the program in the form of the initial and final time (in hour format with separator spaces, for example written in 10:25:36 hours 10 25 36). After that input will be converted to seconds.

jam::jam(int x,int y,int z, int k, int l,int m)
{
masuk :
cout << "Input the beginning of hours: "; cin >> x>>y>>z;
a=x;b=y;c=z;
if ((a<=23) && (b<=59) &&( c<=59)) { jum1= a*3600 + b *60 + c; // Convert to second } else { cout << "wrong input"<<< "input the end of hours: "; cin >> k>>l>>m;
d=k;e=l;f=m;
if ((d<=23) && (e<=59) &&( f<=59)) { jum2= d*3600 + e *60 + f; // Convert to second } else { cout << "wrong input"<<< "cannot compile. Try again?"< jumlah=" jum2-jum1;" g =" jumlah" j =" jumlah" h =" j" i =" j" style="color: rgb(128, 128, 128);">// Choice for calculate price
cin >> input;
if (input == 'a') // Choice for Local
{
bea=jumlah*5;
cout << "Duration = " <<><<":"<<<< "Price = " << else="" input="=" b="">// Choice for inter local
{
bea=jumlah*30;
cout << "Duration = "<<><<":"<<<< "Price = “<< else="" cout=""><< "Wrong input" << style="font-weight: bold;">Program to display the amount of phone time and cost that must be removed.

int main()
{
jam wartel(x,y,z,k,l,m);
wartel.biaya(jumlah,bea);
}

No comments:

Post a Comment