Assignment
Assignment
#include <stdexcept>
#include <string>
class dateType {
public:
private:
int dMonth;
int dDay;
int dYear;
};
if (year < 1900 || month < 1 || month > 12 || day < 1 || day > 31) {
if (month == 2) {
if (isLeapYear(year)) {
} else {
} else if ((month == 4 || month == 6 || month == 9 || month == 11) && day > 30) {
dMonth = month;
dDay = day;
dYear = year;
cout << dMonth << "/" << dDay << "/" << dYear;
class personType {
public:
private:
string firstName;
string lastName;
};
setName(first, last);
firstName = first;
lastName = last;
return firstName;
return lastName;
int main() {
try {
myDate.printDate();
#include <iostream>
#include <stdexcept>
#include <string>
class dateType {
public:
private:
int dMonth;
int dDay;
int dYear;
};
if (month == 2) {
if (isLeapYear(year)) {
} else {
} else if ((month == 4 || month == 6 || month == 9 || month == 11) && (day < 1 || day > 30)) {
throw invalid_argument("Invalid day for the specified month");
dMonth = month;
dDay = day;
dYear = year;
cout << dMonth << "/" << dDay << "/" << dYear;
int main() {
try {
myDate.printDate();
dateType invalidDate;
invalidDate.printDate();
}
}
Question 2;
#include <iostream>
class DateType{
public:
cout << day << "/" << month << "/" << year;
};
class PersonType {
public:
: firstName(fName), lastName(lName) {}
};
public:
string specialty;
disName();
cout<<endl;
};
class BillType {
public:
int patientId;
};
public:
DoctorType attendPhysician;
PatientType(const string& fName, const string& lName, int id, int age,
attendPhysician(physician) {}
disName();
dOfBirth.disDate();
cout<<endl;
cout<<endl;
disDate.disDate();
attendPhysician.disDoctorInfo();
};
int main() {
doctor.disDoctorInfo();
patient.disPatientInfo();
return 0;
}
Question 3;
#include<iostream>
#include<cmath>
class mathematics{
public:
double mean;
double standard_deviation;
double n1,n2,n3,n4,n5;
n1=a;
n2=b;
n3=c;
n4=d;
n5=e;
double Calmean()
mean=(n1+n2+n3+n4+n5)/5;
return mean;
};
public:
A(double n1, double n2, double n3, double n4, double n5)
double Calmean()
mean=(n1+n2+n3+n4+n5)/5;
return mean;
};
public:
B(double n1, double n2, double n3, double n4, double n5)
: mathematics(n1, n2, n3, n4, n5) {}
double CalStandardDeviation()
standard_deviation = sqrt(
return standard_deviation;
};
int main()
double n1,n2,n3,n4,n5;
cin>>n1>>n2>>n3>>n4>>n5;
A xobj(n1,n2,n3,n4,n5);
cout<<xobj.Calmean()<<endl;
B yobj(n1,n2,n3,n4,n5);
cout<<yobj.CalStandardDeviation();
}
Question 4;
#include<iostream>
class dayType{
public:
string
week[7]={"sunday","monday","tuesday","wednesday","thursday","friday","sat
urday"};
string day;
int add;
string afteradd;
string currentday;
dayType(string a,int b)
{
day=a;
add=b;
void printday()
for(int i=0;i<7;i++)
if(day==week[i])
currentday=week[i];
void retday() {
if (day == week[i]) {
currentdayindex = i;
break;
}
}
if (currentdayindex != -1) {
afteradd = week[newdayindex];
cout << "After adding " << add << " days, day is " << afteradd << endl;
} else {
void nextday()
for(int i=0;i<7;i++)
if(day==week[i])
if(week[i]==week[6])
else
void prevday()
for(int i=0;i<7;i++)
if(day==week[i])
if(week[i]==week[0])
else
};
int main()
string day;
int a;
cin>>day;
cin>>a;
dayType obj(day,a);
obj.printday();
obj.nextday();
obj.prevday();
obj.retday();
}
Q 4;
#include <iostream>
class fractionType {
private:
int numer;
int denom;
public:
if (denom == 0) {
return *this;
};
int main() {
resultAdd.display();
resultSub.display();
resultMul.display();
resultDiv.display();
fraction1.display();
fraction2.display();
cout << "Less than: " << boolalpha << isLessThan << endl;
cout << "Greater than: " << boolalpha << isGreaterThan << endl;
return 0;
Q 6;
#include<iostream>
A temp;
temp = var[i];
var[i] = var[j];
var[j] = temp;
int main()
{
int s = 5;
sortion(intvar, s);
sortion(floatvar, s);
sortion(doublevar, s);
return 0;
}
#include <iostream>
class Publication {
public:
string title;
int pub_Year;
return title;
return pub_Year;
virtual ~Publication() {}
};
public:
string author;
int genre;
~Book() {}
};
public:
int issueNo;
~Magazine() {}
};
int main() {
publication1->disDetails();
publication2->disDetails();
delete publication1;
delete publication2;
}