Laboratory 1
Laboratory 1
Objective
The objective of the assignment is to teach you how to develop C++ programs using OOP
techniques. Using OOP encourages the interaction of objects and their functions using
appropriate methods and properties. You are to perform this practical/task using pair
programming technique. Any group exceeding more than two participants per workstation
will neither be attended to nor graded.
Procedure
Follow the instructions as follows:
1. Open up 2019 Microsoft Visual Studio on your laboratory desktop.
2. Read out the instructions in your laboratory manuals properly.
3. Write out the codes in the Visual Studio C++ editor as indicated in the manual. Make
sure you save your codes at intervals.
4. Build and debug your code, if possible for every line. Make sure you print out your
output screen/interface and codes in your report.
5. Submit a report for the two activities on blackboard. However, each first activity will
be graded by the end of the lab.
Grading Rubric (Copy this Rubric onto the first page of your report)
BENCHMARK COMMENTS POINTS Ex 1 Ex 2 Ex 3
IDE proficiency Includes the proficiency of the IDE employed in the 2
course of code/interface development
Specification Analytics Applies to the software specification. Pre-analysis, UML 2
and flow charts for design and implementation
Programming Skills Applies to the reasoning and analytics of software design 4
in code writing and interface design.
Programming Logic and Applies to the logic and flow of the of the written code and
Flow interface designs. A good programme must have the 5
appropriate flow and logic.
Output This is the overall performance of the code/interface
Specification/validation design. Satisfactory realisation of the specifications have 2
been met and validated.
1
ACTIVITY 1.1 (To be graded within the Laboratory period; Report must be submitted
with Activity 1.2)
Write a C++ program using Object Oriented Programming (OOP) style to create a class for
UJ library management. You are to specify correctly, what parameters of your class should
be private, public or protected. Your prograrn may be structured with the following
specification and tasks.
1 #include <iostream>
2 using namespace std;
3 #define MAX 10
4 class student
5 {
6 private:
char name[30];
int rollNo;
int total;
float perc;
7 public:
void getDetails(void);
void putDetails(void);
8 };
9 void student::getDetails(void)
10 {
11 cout << "Enter name: " ;
12 cin >> name;
13 cout << "Enter roll number: ";
14 cin >> rollNo;
15 cout << "Enter total marks out of 500: ";
16 cin >> total;
17 perc=(float)total/500*100;
18 }
2
19 void student::putDetails(void)
20 {
21 cout << "Student details:\n";
22 cout << "Name:"<< name << ",Roll Number:" << rollNo << ",Total:" << total <<
",Percentage:" << perc;
23 }
24 int main()
25 {
26 student std[MAX];
27 int n,loop;
30 for(loop=0;loop< n; loop++){
cout << "Enter details of student " << loop+1 << ":\n";
std[loop].getDetails();
31 }
32 cout << endl;
33 for(loop=0;loop< n; loop++){
cout << "Details of student " << (loop+1) << ":\n";
std[loop].putDetails();
34 }
35 return 0;
36 }