473,394 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

URGENT HELP NEEDED

Problem Statement
One of the local banks is gearing up for a big advertising campaign and
would like to see how long its customers are waiting for service by
teller/service provider at drive-up window. Several employees have been
asked to keep accurate records for the 24-hour drive-up service. The
collected information, which is read from a file, consists of ID number
of the teller; the time the customer arrived in hours and minutes
(arrival time); the time the customer actually was served in hours and
minutes (service time). There is one record in the file for each
customer. A teller can provide services to many customers. Write a
program that does the following:

a) Reads in the wait data from a file name Bank.txt.
b) Computes the Waiting Time for each customer, in minutes. Waiting
time for each customer is calculated by subtracting the service time by
the arrival time.
c) Compute the Average Service Delay Time for each teller. Average
service delay time is calculated for each teller by summing the waiting
time of all customers served by that teller and dividing that sum by
the total number of customers served by the teller.
d) Calculate Average Waiting Time of all customers. Average waiting
time is the sum of all waiting time divided by the number of customers.

e) Prints a summary showing the Average Waiting Time and Average
Service Delay.

Input
A file containing teller ID, arrival time, and service time. The times
are broken up into integer hours and minutes according to a 24-hour
clock.

Output
The program should print on the screen, the Mean Waiting Time and
Average Service delay time for each teller.

In sample input file, first column represents the teller's Id, second
and third columns represent the arrival time in hours and minutes
respectively. Fourth and fifth columns represent the service time in
hours and minutes respectively.

#include<iostream>
#include<fstream>
using namespace std;

struct Time
{
int hour, minutes;
};

struct Customer
{
int id, waiting_time;
Time arr_time, sr_time;
};

int wtime(Customer c)
{
int count=0;
int tame=0;

c.arr_time.minutes=(c.arr_time.hour*60)+c.arr_time .minutes;
c.sr_time.minutes=(c.sr_time.hour*60)+c.sr_time.mi nutes;

tame=c.sr_time.minutes-c.arr_time.minutes;

return tame;
}

int main()
{
Customer array[10]={0};
int count=0;
ifstream a;
ofstream b;
double ave=0;

a.open("bank.txt");
b.open("output.txt");

while(count<10)
{
a>>array[count].id;
a>>array[count].arr_time.hour;
a>>array[count].arr_time.minutes;
a>>array[count].sr_time.hour;
a>>array[count].sr_time.minutes;

count++;
}

count=0;

while(count<10)
{
b<<"Waiting Time is"<<endl;
b<<wtime(array[count]);
ave=ave+wtime(array[count]);
b<<endl;
count++;
}

b<<endl;
ave=ave/10;
b<<"AVerage Waiting Time is"<<endl;
b<<ave<<endl;
b<<endl;

count=0;
int count1=0;
ave=0;
int count2=0;

while(count<4)
{
ave=wtime(array[count]);
count1=count+1;
count2=0;

while(count1<10)
{
if(array[count].id==array[count1].id)
{
ave=ave+wtime(array[count1]);
array[count1].id=0;
count2++;
}
count1++;
}

b<<"Average Waiting Time for ID "<<count+1<<" is"<<endl;
b<<ave/(count2+1)<<endl;
count=count++;
count1=count;
}

return 0;
}

It outputs

Waiting Time is
120
Waiting Time is
90
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
45
Waiting Time is
34

AVerage Waiting Time is
52.9

Average Waiting Time for ID 1 is
75
Average Waiting Time for ID 2 is
50
Average Waiting Time for ID 3 is
41.25
Average Waiting Time for ID 4 is
45

Instead of

Waiting Time is
120
Waiting Time is
90
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
45
Waiting Time is
34

AVerage Waiting Time is
52.9

Average Waiting Time for ID 1 is
75
Average Waiting Time for ID 2 is
50
Average Waiting Time for ID 3 is
41.25
Average Waiting Time for ID 4 is
60

Please Help!

Dec 1 '05 #1
5 1458
coinjo wrote:
Problem Statement
One of the local banks is gearing up for a big advertising campaign and
would like to see how long its customers are waiting for service by
teller/service provider at drive-up window. Several employees have been
asked to keep accurate records for the 24-hour drive-up service. The
collected information, which is read from a file, consists of ID number
of the teller; the time the customer arrived in hours and minutes
(arrival time); the time the customer actually was served in hours and
minutes (service time). There is one record in the file for each
customer. A teller can provide services to many customers. Write a
program that does the following:

a) Reads in the wait data from a file name Bank.txt.
b) Computes the Waiting Time for each customer, in minutes. Waiting
time for each customer is calculated by subtracting the service time by
the arrival time.
c) Compute the Average Service Delay Time for each teller. Average
service delay time is calculated for each teller by summing the waiting
time of all customers served by that teller and dividing that sum by
the total number of customers served by the teller.
d) Calculate Average Waiting Time of all customers. Average waiting
time is the sum of all waiting time divided by the number of customers.

e) Prints a summary showing the Average Waiting Time and Average
Service Delay.

Input
A file containing teller ID, arrival time, and service time. The times
are broken up into integer hours and minutes according to a 24-hour
clock.

Output
The program should print on the screen, the Mean Waiting Time and
Average Service delay time for each teller.

In sample input file, first column represents the teller's Id, second
and third columns represent the arrival time in hours and minutes
respectively. Fourth and fifth columns represent the service time in
hours and minutes respectively.
Please read the following:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.7
http://www.parashift.com/c++-faq-lit...t.html#faq-5.2
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

http://www.parashift.com/c++-faq-lite/containers.html
#include<iostream>
#include<fstream>
using namespace std;

struct Time
{
int hour, minutes;
};

struct Customer
{
int id, waiting_time;
Time arr_time, sr_time;
};

int wtime(Customer c)
{
int count=0;
int tame=0;

c.arr_time.minutes=(c.arr_time.hour*60)+c.arr_time .minutes;
c.sr_time.minutes=(c.sr_time.hour*60)+c.sr_time.mi nutes;

tame=c.sr_time.minutes-c.arr_time.minutes;

return tame;
}

int main()
{
Customer array[10]={0};
int count=0;
ifstream a;
ofstream b;
double ave=0;

a.open("bank.txt");
b.open("output.txt");

while(count<10)
{
a>>array[count].id;
a>>array[count].arr_time.hour;
a>>array[count].arr_time.minutes;
a>>array[count].sr_time.hour;
a>>array[count].sr_time.minutes;

count++;
}

count=0;

while(count<10)
{
b<<"Waiting Time is"<<endl;
b<<wtime(array[count]);
ave=ave+wtime(array[count]);
b<<endl;
count++;
}

b<<endl;
ave=ave/10;
b<<"AVerage Waiting Time is"<<endl;
b<<ave<<endl;
b<<endl;

count=0;
int count1=0;
ave=0;
int count2=0;

while(count<4)
{
ave=wtime(array[count]);
count1=count+1;
count2=0;

while(count1<10)
{
if(array[count].id==array[count1].id)
{
ave=ave+wtime(array[count1]);
array[count1].id=0;
count2++;
}
count1++;
}

b<<"Average Waiting Time for ID "<<count+1<<" is"<<endl;
b<<ave/(count2+1)<<endl;
count=count++;
count1=count;
}

return 0;
}

It outputs

Waiting Time is
120
Waiting Time is
90
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
45
Waiting Time is
34

AVerage Waiting Time is
52.9

Average Waiting Time for ID 1 is
75
Average Waiting Time for ID 2 is
50
Average Waiting Time for ID 3 is
41.25
Average Waiting Time for ID 4 is
45

Instead of

Waiting Time is
120
Waiting Time is
90
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
30
Waiting Time is
60
Waiting Time is
30
Waiting Time is
45
Waiting Time is
34

AVerage Waiting Time is
52.9

Average Waiting Time for ID 1 is
75
Average Waiting Time for ID 2 is
50
Average Waiting Time for ID 3 is
41.25
Average Waiting Time for ID 4 is
60

Please Help!

Dec 1 '05 #2
coinjo wrote:

Please Help!


Help with what?

It seems you have a working program. That program,
produces some output. That output might or
might not be correct. I can't say because I don't
know the input data.

Where is your problem?

--
Karl Heinz Buchegger
kb******@gascad.at
Dec 1 '05 #3
Gabriel wrote:

[...}
Average Waiting Time for ID 3 is
41.25
Average Waiting Time for ID 4 is
45

Instead of
[...] Average Waiting Time for ID 3 is
41.25
Average Waiting Time for ID 4 is
60


Oh. I see.
You posted lots of text to figure just to let us
figure out that your numbers are not what they
should be in one place.

Add additional output statements to your program, to figure
out in which way the program came up with a value of 60.
*You* need to understand where that value 60 comes from.
Then you will know
* either: where to look further to figure the whole thing out
* or: how to fix it.

Sorry. But this is programming. Debuggin code is an integral
part of programming and you need to develop some skills in it.
As long as only 1 value as the result of some simple calculations
is not what it should, debugging is really not a big problem.
So go ahead and tackle that problem.

Note: Most newbies have some fear in introducing additional output
statements in their code. There is nothing to worr about. It is
just a normal process and can be undone easily when the program logic
is fixed.
If the average waiting time for some teller is wrong, I would start
with outputting the waiting times for tellers (in addition to the average).
Then compare that with the input file. What to do next depends on what
that comparison comes up with.

--
Karl Heinz Buchegger
kb******@gascad.at
Dec 1 '05 #4
Karl Heinz Buchegger wrote:

Note: Most newbies have some fear in introducing additional output
statements in their code. There is nothing to worr about. It is
just a normal process and can be undone easily when the program logic
is fixed.
If the average waiting time for some teller is wrong, I would start
with outputting the waiting times for tellers (in addition to the average).
Then compare that with the input file. What to do next depends on what
that comparison comes up with.


Another hint:
When reading input either from the user or from a file, it
is *always* a good idea to output immediatly what the program
has read and compare that with what it should read. You
are not the first one who spent lots of time in analysing
some calculations just to figure out after some hours, that
the calculation is correct, but the input fed to it is not.

--
Karl Heinz Buchegger
kb******@gascad.at
Dec 1 '05 #5
"coinjo" <co****@gmail.com> writes:
Problem Statement
[ long homework assignment snipped ]
Please Help!


It would be easier to help you if you tell us what you need help
with. What is your problem? You just posted a long text describing
your assignment, some code, and some output, but you didn't tell
us what you need help with. (Nobody here is going to do your
homework for you, but we will help you by pointing you in the
right direction if you can be a bit more specific.

/Niklas Norrthon
Dec 1 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: choksi | last post by:
Hello All I am running PHP5.0.2 over apache 1.3.29 and openssl-0.9.7d on a Debian Linux and with a fake (internal)ip. Php Configure command './configure' '--with-apxs=/www/bin/apxs'...
10
by: Tony Archer | last post by:
Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a production box. On the dev box everything works fine, in production it hoses: One of...
1
by: Tony Archer | last post by:
(Forgive the dupicate post, I had left out the OS Version out of the prior post.) Gentlemen, your urgent help is needed in solving a STRANGE problem. I have two servers a dev box, and a...
0
by: felix_william | last post by:
Attention=3A Dear friend=2C REQUEST FOR BUSINESS RELATIONSHIP OF GREAT PROFITS I am HON=2E =28DR=2E=29 Felix William=2C the Director of Procurement and Contract Award at the Nigerian National...
12
by: Vibhajha | last post by:
Hi friends, My sister is in great problem , she has this exam of C++ and she is stuck up with some questions, if friends like this group provides some help to her, she will be very grateful....
4
by: Random | last post by:
The way I've built my page is to take the user through a multi-form process, only rendering those controls that are needed for each section. The ViewState is working the way I want it to,...
7
by: meenasamy | last post by:
Hi all, i need to create a function that takes three parameters( Original currency, needed currency, amount) i need to convert from the original currency to the needed currency the amount and...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
2
by: Preetam Pattanashetty | last post by:
Hi I am learning ASP.NET using C#. I am able to run .aspx files on local system, but when I load them to the server, I get the "Server Error in '/' Application" error. I have tried to configure the...
0
by: Christopher | last post by:
Urgent Help Needed: The EPVH-1.1 Visual Hull Library. Dear All, I am a student doing research in computer vision. The EPVH-1.1 Visual Hull Library will really help a lot in my research. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.