24k2027_L1
24k2027_L1
CLASS BSSE
ROLL NO 24K2027
ASSIGNMENT 01
CODE
#include<iostream>
#include<string>
using namespace std;
class num
{
int m;
public:
void input()
{
cout<<"enter the value "<<endl;
cin>>m;
}
void shoe()
{
cout<<"the number is "<<m<<endl;
}
};
int main()
{ num obj;
obj.input();
obj.shoe();
system("pause");
return 0;
}
OUTPUT
CODE
#include <iostream>
using namespace std;
// Class definition
class Distance {
private:
int feet; // Integer for feet
float inches; // Float for inches
public:
// Function to get distance from user
void getDist() {
cout << "Enter feet: ";
cin >> feet;
cout << "Enter inches: ";
cin >> inches;
}
int main() {
Distance d1, d2; // Create two Distance objects
OUTPUT
CODE
#include <iostream>
using namespace std;
class time {
private:
int hours ;
int mintues;
int seconds;
public:
hours =a;
mintues=b;
seconds=c;
void showtime() {
cout << "time " << hours << " " << mintues << " " <<seconds<< endl;
}
};
int main() {
time t1, t2;
t1.settime(12,13,15);
t2.settime(12,13,15);
cout << "first time is:" << endl;
t1.showtime();
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class Person {
private:
int Pid;
string Pname;
float PSalary;
public:
void getData() {
cout << "Enter Person ID: ";
cin >> Pid;
cout << "Enter Name: ";
cin>>Pname;
cout << "Enter Salary: ";
cin >> PSalary;
}
void showData() {
cout<<"pid is"<<Pid<<"name is"<<Pname<<"salary is "<<PSalary<<endl;
}
float getSalary() {
return PSalary;
}
};
int main() {
Person p1, p2, p3;
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class Employee {
private:
int Eid;
string Ename;
double ESalary;
public:
void getData() {
cout << "Enter Person ID: ";
cin >> Eid;
cin.ignore();
cout << "Enter Name: ";
getline(cin ,Ename);
cout << "Enter Salary: ";
cin >> ESalary;
}
void showData() {
cout<<"eid "<<Eid<<"name is "<<Ename<<"salary is "<<ESalary<<endl;
}
double getSalary() {
return ESalary;
}
};
int main() {
Employee p1, p2;
cout << "Enter details for Employee 1:" << endl;
p1.getData();
cout << "Enter details for Employee 2:" << endl;
p2.getData();
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class student {
private:
int eng;
int che;
int bio;
int math;
int phy;
public:
void getData() {
cout << "Enter eng numbre: ";
cin >> eng;
cout << "Enter che number: ";
cin>>che;
cout << "Enter bio number: ";
cin >> bio;
cout << "Enter math number: ";
cin >> math;
cout << "Enter phy number: ";
cin >> phy;
}
int sum() {
int sum;
sum=eng+che+bio+math+phy;
return sum;
int average() {
float average;
average=(sum()/5);
return average;
}
};
int main() {
student p1;
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class Student {
private:
int admno;
string sname;
float eng, math, science, total;
float ctotal() {
return eng + math + science;
}
public:
void Takedata() {
cout << "Enter Admission Number: ";
cin >> admno;
cin.ignore();
cout << "Enter Student Name: ";
getline(cin, sname);
cout << "Enter English Marks: ";
cin >> eng;
cout << "Enter Math Marks: ";
cin >> math;
cout << "Enter Science Marks: ";
cin >> science;
total = ctotal();
}
void Showdata() {
cout << "\nStudent Details" << endl;
cout << "Admission Number: " << admno << endl;
cout << "Student Name: " << sname << endl;
cout << "English Marks: " << eng << endl;
cout << "Math Marks: " << math << endl;
cout << "Science Marks: " << science << endl;
cout << "Total Marks: " << total << endl;
}
};
int main() {
Student student;
student.Takedata();
student.Showdata();
system("pause");
return 0;
}
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class Batsman {
private:
int bcode;
string bname;
int innings, notout, runs;
float batavg;
void calcavg() {
if (innings - notout > 0)
batavg = static_cast<float>(runs) / (innings - notout);
else
batavg = 0; // To handle division by zero case
}
public:
void readdata() {
cout << "Enter Batsman Code (4-digit number): ";
cin >> bcode;
cin.ignore();
cout << "Enter Batsman Name: ";
getline(cin, bname);
cout << "Enter Innings Played: ";
cin >> innings;
cout << "Enter Not Out Innings: ";
cin >> notout;
cout << "Enter Total Runs Scored: ";
cin >> runs;
calcavg();
}
void displaydata() {
cout << "\nBatsman Details" << endl;
cout << "Batsman Code: " << bcode << endl;
cout << "Batsman Name: " << bname << endl;
cout << "Innings Played: " << innings << endl;
cout << "Not Out Innings: " << notout << endl;
cout << "Total Runs: " << runs << endl;
cout << "Batting Average: " << batavg << endl;
}
};
int main() {
Batsman batsman;
batsman.readdata();
batsman.displaydata();
system("pause");
return 0;
}
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class TEST {
private:
int TestCode;
string Description;
int NoCandidate;
int CenterReqd;
int CALCNTR() {
return (NoCandidate / 100) + 1;
}
public:
void SCHEDULE() {
cout << "Enter Test Code: ";
cin >> TestCode;
cin.ignore();
cout << "Enter Description: ";
getline(cin, Description);
cout << "Enter Number of Candidates: ";
cin >> NoCandidate;
CenterReqd = CALCNTR();
}
void DISPTEST() {
cout << "\nTest Details" << endl;
cout << "Test Code: " << TestCode << endl;
cout << "Description: " << Description << endl;
cout << "Number of Candidates: " << NoCandidate << endl;
cout << "Number of Centers Required: " << CenterReqd << endl;
}
};
int main() {
TEST test;
test.SCHEDULE();
test.DISPTEST();
system("pause");
return 0;
}
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class Flight {
private:
int FlightNumber;
string Destination;
float Distance;
float Fuel;
void CALFUEL() {
if (Distance <= 1000)
Fuel = 500;
else if (Distance > 1000 && Distance <= 2000)
Fuel = 1100;
else
Fuel = 2200;
}
public:
void FEEDINFO() {
cout << "Enter Flight Number: ";
cin >> FlightNumber;
cin.ignore();
cout << "Enter Destination: ";
getline(cin, Destination);
cout << "Enter Distance: ";
cin >> Distance;
CALFUEL();
}
void SHOWINFO() {
cout << "\nFlight Details" << endl;
cout << "Flight Number: " << FlightNumber << endl;
cout << "Destination: " << Destination << endl;
cout << "Distance: " << Distance << " km" << endl;
cout << "Fuel Required: " << Fuel << " liters" << endl;
}
};
int main() {
Flight flight;
flight.FEEDINFO();
flight.SHOWINFO();
system("pause");
return 0;
}
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class BOOK {
private:
int BOOK_NO;
string BOOKTITLE;
float PRICE;
float TOTAL_COST(int N) {
return PRICE * N;
}
public:
void INPUT() {
cout << "Enter Book Number: ";
cin >> BOOK_NO;
cin.ignore();
cout << "Enter Book Title: ";
getline(cin, BOOKTITLE);
cout << "Enter Price per Copy: ";
cin >> PRICE;
}
void PURCHASE() {
int N;
cout << "Enter number of copies to purchase: ";
cin >> N;
float total = TOTAL_COST(N);
cout << "Total Cost: " << total << "\n";
}
};
int main() {
BOOK book;
book.INPUT();
book.PURCHASE();
system("pause");
return 0;
}
OUTPUT
CODE
#include <iostream>
#include <string>
using namespace std;
class REPORT {
private:
int adno;
string name;
float marks[5];
float average;
void GETAVG() {
float sum = 0;
for (int i = 0; i < 5; i++) {
sum += marks[i];
}
average = sum / 5;
}
public:
void READINFO() {
cout << "Enter Admission Number (4 digits): ";
cin >> adno;
cin.ignore();
cout << "Enter Name: ";
getline(cin, name);
cout << "Enter Marks for 5 Subjects: ";
for (int i = 0; i < 5; i++) {
cin >> marks[i];
}
GETAVG();
}
void DISPLAYINFO() {
cout << "\nStudent Report" << endl;
cout << "Admission Number: " << adno << endl;
cout << "Name: " << name << endl;
cout << "Marks: ";
for (int i = 0; i < 5; i++) {
cout << marks[i] << " ";
}
cout << "\nAverage Marks: " << average << endl;
}
};
int main() {
REPORT student;
student.READINFO();
student.DISPLAYINFO();
system("pause");
return 0;
}
OUTPUT