Vous êtes sur la page 1sur 4

National University of Computer & Emerging Sciences Department of Electrical Engineering

EL110 Programming for Engineers I LAB Fall 2011

Lab Final- Total Marks: 40 , Time 2hrs


Question-1
Problem Statement: (15 marks) Estimated Time: 45 min

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.

Page 1 of 4

National University of Computer & Emerging Sciences Department of Electrical Engineering

In sample input file, first column represents the tellers 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.

Sample Input File Bank.txt


1 2 2 1 3 3 4 2 2 3 5 5 5 1 30 0 30 0 0 30 0 4 3 4 6 5 6 2 30 30 0 0 30 0 0

Sample Output
Average Waiting Time: Average Service Delay: 1 90 2 60 3 30 4 60 60

Page 2 of 4

National University of Computer & Emerging Sciences Department of Electrical Engineering

Question-2

Problem Statement: (15 marks)

Estimated Time: 45 min

A prime number is any integer that is evenly divisible only by itself and 1. The Sieve of Eratosthenes is a method of finding prime numbers. It operates as follows: Create an array with all elements initialized to 1 (true). Array elements with prime subscripts will remain 1. All other array elements will eventually be set to zero. Starting with array subscript 2 (subscript 1 must be prime), every time an array element is found whose value is 1, loop through the remainder of the array and set to zero every element whose subscript is a multiple of the subscript for the element with value 1. For array subscript 2, all elements beyond 2 in the array that are multiples of 2 will be set to zero (subscripts 4, 6, 8, 10, etc.); for array subscripts 3, all elements beyond 3 in the array that are multiples of 3 will be set to zero (subscripts 6, 9, 12, 15, etc.); and so on.

When this process is complete, the array elements that are still set to one indicate that the subscript is a prime number. These subscripts can then be printed. Write a program that uses an array of 100 elements to determine and print the prime numbers between 1 and 99. Ignore element 0 of the array.

Page 3 of 4

National University of Computer & Emerging Sciences Department of Electrical Engineering

Question-3

Problem Statement: (10 marks)

Estimated Time: 30 min

You want to conduct a survey within your classroom, on the quality of canteens food. You ask each of your class fellows to rank the quality of food between 1 and 5 (1 representing excellent quality and 5 representing worst quality). During the survey, you make a list containing the roll# of student and the opinion given by that student. The list can be as follow Roll # 234 235 236 237 238 239 240 241 242 Opinion 1 1 5 1 2 3 5 5 1

To get the results of the survey, you need to determine the frequency of each opinion value. The frequency of an opinion is determined by counting the number of students giving that opinion. For example, for the above list the frequency of opinion value 1 is 4 and frequency of opinion value 4 is 0. After getting the frequency of each opinion, you can easily judge about the quality of the food by seeing through the frequency of each opinion. You need to develop a program to calculate the results of this survey. The program inputs the opinion of 10 students and counts the frequency of each opinion. It then displays a report showing the frequency of each opinion.

Page 4 of 4