Lab Task 5
Lab Task 5
#include <iostream>
class Person {
private:
string name;
int age;
public:
name = newName;
age = newAge;
void displayInfo() {
};
int main() {
Person person;
person.setName("Rahim");
person.setAge(25);
person.displayInfo();
return 0;
}
Problem 2
#include <iostream>
class BankAccount {
private:
string accountNumber;
string accountHolder;
double balance;
public:
accountNumber = move(number);
accountHolder = move(holder);
balance = initialBalance;
if (amount > 0) {
balance += amount;
cout << "Deposit of $" << amount << " successful.\n";
} else {
balance -= amount;
} else {
void displayBalance() {
};
int main() {
account.deposit(500);
account.displayBalance();
cout<<endl;
account.withdraw(200);
account.displayBalance();
cout<<endl;
account.withdraw(1000);
account.displayBalance();
cout<<endl;
return 0;
Problem 3
#include <iostream>
class Student {
private:
string name_;
int rollNumber_;
int marks_;
public:
name_ = name;
rollNumber_ = rollNumber;
marks_ = marks;
}
void setName(string name) {
name_ = name;
rollNumber_ = rollNumber;
void displayInfo(){
};
int main() {
Student student("Rahim",20);
student.displayInfo();
return 0;
}
Problem 4
#include <iostream>
class Book{
private:
string title;
string author;
int publicationYear;
public:
title = bookTitle;
author = bookAuthor;
publicationYear = year;
void DisplayDetails(){
cout<<"Title: "<<title<<endl;
cout<<"Author: "<<author<<endl;
};
int main(){
Book myBook;
myBook.DisplayDetails();
return 0;
}
Problem 5
#include <iostream>
class Car {
private:
string make;
string model;
int year;
public:
make = carMake;
model = carModel;
year = carYear;
}
void DisplayCarInfo() {
};
int main() {
Car myCar;
myCar.setMake("Toyota");
myCar.setModel("Camry");
myCar.setYear(2023);
myCar.DisplayCarInfo();
return 0;
Problem 6
#include <iostream>
using namespace std;
class TimeConverter {
private:
int hours;
int minutes;
int seconds;
public:
hours = h;
minutes = m;
seconds = s;
int ConvertToTotalSeconds() {
};
int main() {
TimeConverter myTime;
return 0;