Programs
Programs
#include<iostream>
#include<conio.h>
using namespace std;
class angle
{
private:
int degree;
float minute;
char direction;
public:
angle()
{
degree = 0;
minute = 0;
direction = 0;
}
angle(int a , float b, char c)
{
degree = a;
minute = b;
direction = c;
}
void obtain_angle();
void display_angle_of_Latitude();
void display_angle_of_Longitude();
void set_angle(int,float,char);
int get_angle();
};
This study source was downloaded by 100000822375251 from CourseHero.com on 03-19-2022 15:32:58 GMT -05:00
https://www.coursehero.com/file/91088924/Programsdocx/
{
cout << "Enter degree : ";
cin >> degree;
cout << "Enter minute : ";
cin >> minute;
cout << "Enter direction : ";
cin >> direction;
return degree;
return minute;
return direction;
}
int main()
{
cout << "Angle Initialized with constructor :- \n";
angle Longitude(106, 14.7, 'E');
angle Latitude(44, 20.6, 'N');
Longitude.display_angle_of_Longitude();
Latitude.display_angle_of_Latitude();
cout << "--------------------------------";
int z;
cout << "\nLoop Body :- \n";
cout << "How many times you want to run Loop ? : ";
cin >> z;
cout << "\nEnter THE Values for Longitude :- " << endl;
Longitude.get_angle();
Longitude.display_angle_of_Longitude();
cout << "\nEnter THE values for Latitude :- " << endl;
Latitude.get_angle();
Latitude.display_angle_of_Latitude();
_getch();
return 0;
This study source was downloaded by 100000822375251 from CourseHero.com on 03-19-2022 15:32:58 GMT -05:00
https://www.coursehero.com/file/91088924/Programsdocx/
}
#include<iostream>
#include<conio.h>
using namespace std;
class angle
{
private:
int degree;
float minute;
char direction;
public:
angle();
angle(int a, float b, char c);
void obtain_angle();
void longitude();
void latitude();
};
angle::angle()
{
degree = 0;
minute = 0;
direction = 0;
}
angle:: angle(int a, float b, char c)
{
degree = a;
minute = b;
direction = c;
}
void angle :: obtain_angle()
{
cout << "Enter Degrees = ";
cin >> degree;
cout << "Enter minutes = ";
cin >> minute;
cout << "Enter Direction = ";
cin >> direction;
}
void angle::longitude()
{
cout << "Value of Longitude is = " << degree << "\xF8" << minute << "\'" <<
direction << endl;
}
void angle ::latitude()
{
cout << "Value of Latitude is = " << degree << "\xF8" << minute << "\'" <<
direction << endl;
}
int main()
{
angle Longi, legi;
Longi.obtain_angle();
This study source was downloaded by 100000822375251 from CourseHero.com on 03-19-2022 15:32:58 GMT -05:00
https://www.coursehero.com/file/91088924/Programsdocx/
cout << endl;
Longi.longitude();
legi.obtain_angle();
cout << endl;
legi.latitude();
_getch();
return 0;
}
2)
#include <iostream>
#include<conio.h>
using namespace std;
class Serial
{
private:
static int count;
int number;
public:
Serial();
void set_value();
void display_value();
};
Serial::Serial()
{
number = 0;
}
void Serial:: set_value()
{
number = ++count;
}
void Serial:: display_value()
{
set_value();
cout << " ==> I am object number : " << number << "\n";
}
int Serial::count = 0;
int main()
{
Serial object_1;
Serial object_2;
Serial object_3;
object_1.display_value();
object_2.display_value();
This study source was downloaded by 100000822375251 from CourseHero.com on 03-19-2022 15:32:58 GMT -05:00
https://www.coursehero.com/file/91088924/Programsdocx/
object_3.display_value();
_getch();
return 0;
}
3)
#include<iostream>
#include<conio.h>
using namespace std;
class angle
{
private:
int degree;
float minute;
char direction;
public:
angle();
angle(int a, float b, char c);
void obtain_data();
void display_angle_of_Longitude();
void display_angle_of_Latitude();
};
angle::angle()
{
degree = 0;
minute = 0;
direction = 0;
}
angle::angle(int a, float b, char c)
{
degree = a;
minute = b;
direction = c;
}
void angle:: obtain_data()
{
cout << "Enter Degrees : ";
cin >> degree;
cout << "Enter minutes : ";
cin >> minute;
cout << "Enter Direction : ";
cin >> direction;
}
void angle :: display_angle_of_Longitude()
{
cout << "Longitude ==> " << degree << "\xF8" << minute << "\'" << direction
<< endl;
}
void angle:: display_angle_of_Latitude()
{
This study source was downloaded by 100000822375251 from CourseHero.com on 03-19-2022 15:32:58 GMT -05:00
https://www.coursehero.com/file/91088924/Programsdocx/
cout << "Latitude ==> " << degree << "\xF8" << minute << "\'" << direction <<
endl;
}
class ship
{
private:
angle Longitude;
angle Latitude;
int ship_number;
static int count;
public:
void ship_position();
void display();
};
int main()
{
ship ship_1, ship_2, ship_3;
This study source was downloaded by 100000822375251 from CourseHero.com on 03-19-2022 15:32:58 GMT -05:00
https://www.coursehero.com/file/91088924/Programsdocx/
cout << endl;
_getch();
return 0;
}
This study source was downloaded by 100000822375251 from CourseHero.com on 03-19-2022 15:32:58 GMT -05:00
https://www.coursehero.com/file/91088924/Programsdocx/
Powered by TCPDF (www.tcpdf.org)