Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
1Activity
0 of .
Results for:
No results containing your search query
P. 1
MEK3170-A1-2007

MEK3170-A1-2007

Ratings: (0)|Views: 32|Likes:
Published by api-3845857

More info:

Published by: api-3845857 on Oct 18, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

05/09/2014

pdf

text

original

THE OPEN UNIVERSITY OF SRI LANKA
DIPLOMA IN TECHNOLOGY - LEVEL 3
ACADEMIC YEAR 2007/2008
MEK3170 C PROGRAMMING
ASSIGNMENT #1
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
appropriatecomme nts 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 \u2018MEK3170_A1_2007_your student number\u2019 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: wsnan@ou.ac.lk
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
1990
1995
2000
2005
No. of Students
enrolled
15000
19000
19000
25000
Table 2.1 \u2013 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.
\ue000For each year, two equal rows need to be declared in order to properly represent a
single \u2018bar\u2019 in the chart.
\ue000In 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
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
--- MENU ---

1. Calculating the current in an electrical circuit.
2. Calculating the acceleration of a car.
3. Calculating the intercept of a straight line graph.

4. Quit.
\ue000Option 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), andR is the
resistance.
\ue000Option 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
2
2
1at
ut
S
+
=
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
\ue000Option 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

\ue000Option 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 \u2018menu\u2019 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

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->