0% found this document useful (0 votes)
8 views4 pages

Ooc Labprogram

The document outlines 10 experiments for an Object Oriented Programming Concepts lab course. The experiments cover topics like classes, objects, constructors, inheritance, polymorphism, packages, multi-threading, and event handling using C++ and Java. The first experiment involves creating a Student class with attributes and displaying student objects. The second develops a calculator class using function overloading for arithmetic operations on integers and floats.

Uploaded by

naveen.aptra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
8 views4 pages

Ooc Labprogram

The document outlines 10 experiments for an Object Oriented Programming Concepts lab course. The experiments cover topics like classes, objects, constructors, inheritance, polymorphism, packages, multi-threading, and event handling using C++ and Java. The first experiment involves creating a Student class with attributes and displaying student objects. The second develops a calculator class using function overloading for arithmetic operations on integers and floats.

Uploaded by

naveen.aptra
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 4

Department: CSE/ISE/CSE(AI&ML)

Course Name: Object Oriented Programming Concepts


Course Code: CS322I3C
Lab Programs
Exp. No. Experiment Description

Implement a C++ Program to demonstrate the concepts of Class, Object and Constructors by creating a class
1.
that holds the basic information of students belonging to an Engineering College.

Develop a C++ Program to simulate a calculator that performs basic arithmetic operations on integer and
2.
floating point numbers using the concepts of function overloading.

Write a Java Program for demonstrating creation of Java classes, objects, constructors, declaration and
3.
initialization of variables.

4. Demonstrate the for, for-each, while and do-while loops using a Java Program

5. Implement a Java Program to illustrate the concept of Inheritance, polymorphism

Develop a Java Program to create Java package and illustrate the process of importing a user defined Java
6.
Package .

7. Implement a Java Program to demonstrate of Bounded buffer problems using Java Multi-Threading concepts

8. Implement a Java Program to demonstration of producer-consumer problems

9. Develop a Java program to simulate Key Event and Mouse Event

10. Develop a Java program to demonstrate the java swings

1. Implement a C++ Program to demonstrate the concepts of Class, Object and Constructors by
creating a class that holds the basic information of students belonging to an Engineering
College.

#include <iostream>
#include <string>
using namespace std;
class Student {
string name;
string usn;
string branch;
float cgpa;
public:
// Constructor to initialize the student's information
Student(string sname, string susn, string sbranch, float scgpa) {
name = sname;
usn=susn;
branch=sbranch;
cgpa=scgpa;
}

// Function to display student details


void display ( ) {
cout << "NAME: " << name << endl;
cout << "USN: " << usn << endl;
cout << "BRANCH: " << branch << endl;
cout << "CGPA: " << cgpa<< endl;
}
};

int main( ) {
// Creating objects of Student class
Student s1 ("Ganaraj", "4SF21CI001", "CSE-AIML", 9.5);
Student s2 ("Manjunath", "4SF21AD002", " AI&DS", 9.0);
Student s3 ("Sandra", "4SF21CS003", " CSE", 8.6);
Student s4 ("Naveen", "4SF21IS002", " ISE", 9.0);

// Displaying student information using objects


cout << "Student 1 Details: " << endl;
s1.display ( );
cout << "\nStudent 2 Details: " << endl;
s2.display( );
cout << "\nStudent 3 Details: " << endl;
s3.display( );
cout << "\nStudent 4 Details: " << endl;
s4.display( );
return 0;
}
2. Develop a C++ Program to simulate a calculator that performs basic arithmetic operations on
integer and floating point numbers using the concepts of function overloading.

//Need to work on this


#include <iostream.h>
using namespace std;

class Calculator {
public:
// Function to add two integers
int calculate(int num1, int num2) {
return num1 + num2;
}

// Function to subtract two integers


int calculate(int num1, int num2, char operation) {
if (operation == '-') {
return num1 - num2;
} else {
cout << "Invalid operation for integers!" << endl;
return 0;
}
}

// Function to multiply two integers


int calculate(int num1, int num2, int num3) {
return num1 * num2 * num3;
}

// Function to divide two floating-point numbers


float calculate(float num1, float num2) {
if (num2 != 0) {
return num1 / num2;
} else {
cout << "Cannot divide by zero!" << endl;
return 0.0f;
}
}
};

int main() {
Calculator calc;

// Operations with integers


cout << "Integer calculations:" << endl;
cout << "Addition: " << calc.calculate(5, 3) << endl;
cout << "Subtraction: " << calc.calculate(8, 4, '-') << endl;
cout << "Multiplication: " << calc.calculate(2, 3, 4) << endl;

// Operations with floating-point numbers


cout << "\nFloating-point calculations:" << endl;
cout << "Division: " << calc.calculate(10.5f, 2.0f) << endl;

return 0;
}

You might also like