1. Answer all 4 Questions. Mark allocations are given under each question. 2. Marks will be given for proper comments of the programmes. Therefore, use appropriate comments in all programmes. 3. Write your registration number and name as a C++ comment at the end of each programme you submit. 4. Programmes should be named as Question1.cpp, Question2.cpp etc. The text file, object file and the executable file of each programme should be submitted. You should copy all the programmes (programming codes) that you have written into a word document and this also needs to be submitted along with the programmes. 5. Put all above mentioned files in to a folder and name the folder as ‘MEK3170_A1_2007_your student number’ and zip the folder and upload it to the OUSL Moodle site. You can log onto the OUSL Moodle site using the following links displayed in the OUSL home page
The OUSL Developers' Moodle6 The OUSL Developers' Moodle8

6. Last date of submission is 3rd September 2007 7. Penalties will apply for late submissions 8. If you need further clarification, you may contact the academic coordinator via email Email:

Question 1
Write a programme which prints the following, using an Iteration Structure (a loop) 10, 20, 30, 40, 60, 70, 80, 90,100. Note: Use proper programming techniques in order to make sure the value 50 will not be printed. (10 marks)

Question 2
Page 1 of 5

Table 2.1 shows some rough estimates of the number of students enrolled to the OUSL in the given four years. Year No. of Students enrolled 1990 15000 1995 19000 2000 19000 2005 25000

Table 2.1 – Student Enrolment Details Define four variables to store the above values in your programme. Plot a bar chart as given below to show the student enrolments in each year.

 For each year, two equal rows need to be declared in order to properly represent a single ‘bar’ in the chart.  In a single row, one asterisk (*) should represent 1000 students Example: 10 asterisks for 10000 students (25 marks)

Question 03
Write a programme which display the following menu --- MENU --1. 2. 3. 4. Calculating the current in an electrical circuit. Calculating the acceleration of a car. Calculating the intercept of a straight line graph. Quit.

The user should be given the opportunity to enter either option using the keyboard (by pressing keys 1, 2, 3 or 4).

Page 2 of 5

 Option 1. When the user select this option, your programme should give the user the opportunity to enter the voltage (V) and resistance (R) of a given electrical circuit and your programme should calculate the current (I) and display the result. Use the formula given below in your calculations. I=V/R I=Current, V=Potential difference (ex. voltage drop or voltage), and R is the resistance.  Option 2: When the user selects this option, your programme should give the user the opportunity to enter distance(s), time(t) and initial velocity(u) and your programme should calculate the acceleration. Use the formula given below in your calculations 1 S = ut + at 2 2 u=initial velocity, t = time taken, s = distance Note: If the user enters a negative value for time (t) your programme should display an error message since time cannot be a negative value  Option 3: When the user selects this option, your programme should give the user the opportunity to enter the x and y coordinates. The gradient (m) of the graph is a fixed value, which is equal to 4. Then your programme should calculate the y intercept of the graph . Use the formulae given below in your calculations. y = mx + c x and y are the coordinates of the graph m - gradient c - the y intercept  Option 4: When the user selects this option, your programme should quit. Note: In either option 1,2 or 3 after displaying the answers, your programme should clear the screen and display the ‘menu’ again when the user hit any key. Your programme should quit only when the user select option 4. (25 marks)

Question 4
The table given below shows a typical example in calculating the Electricity bills in Sri Lanka. Example: Electricity consumption in units: 270 Page 3 of 5

Block 1st Block 2nd Block 3rd Block 4th Block 5th Block Fixed Charge Fuel surcharge Total Amount

No. of Units 30 60 (31-90) 30 (61-90) 90 (90 to 180) above 180 if units > 90 Unit charges +Fuel + Fixed

Prorated Units for 30 days 30 60 30 90 balance 60

Rate per Unit Rs. 3.00 4.50 7.80 15.00 20.30 3162.00*20%

Charges Rs. 90.00 270.00 234.00 1350.00 1218.00 240.00 632.40 4,034.40

Charges for the month 4,034.40 Table 4.1 – Example of an Electricity consumption Bill There are 3 types of customers. Regular Customers (R or r), Concession Customers (C or c) and Business Customers (B or b). For regular customers the electricity bill will be calculated exactly as given in the above example. For Concession customers 10% from the total amount will be reduced and for the Business customers 10% of extra charge will be added to the total bill. At the start of your programme, the customers should be given the opportunity to enter his/her monthly electricity consumption in units and his/her customer type. Customer type can be denoted by characters as given above. Your programme should work when the customer enter either a capital or a simple character and should display the following bill. Customer Type: R Amount (Rs) Charge for 280 units Monthly fixed charge 20% Fuel Surcharge Total amount Concession Additional Charges Total Charge Your Total Electricity Charge is Rs. 4034.40 3162.00 240.00 632.40 4034.40 0.00 0.00 4034.40

Page 4 of 5

Note: If there is no fuel surcharge (if the monthly consumption units are less than 90), and no concessions or additional charges, your programme should display the value 0 under ‘Amount’. (40 marks)

Page 5 of 5

Sign up to vote on this title
UsefulNot useful