1)
#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();
};
void angle :: obtain_angle()
{
cout << "Enter Degrees : ";
cin >> degree;
cout << "Enter minutes : ";
cin >> minute;
cout << "Enter Direction : ";
cin >> direction;
}
void angle::display_angle_of_Longitude()
{
cout << "The Longitude is : " << degree << "\xF8" << minute << "\'" <<
direction << endl;
}
void angle :: display_angle_of_Latitude()
{
cout << "The Latitude is : " << degree << "\xF8" << minute << "\'" <<
direction << endl;
}
void angle::set_angle(int x,float y, char z)
{
degree = x;
minute = y;
direction = z;
}
int angle::get_angle()
This study source was downloaded by 100000822375251 from [Link] on 03-19-2022 15:32:58 GMT -05:00
[Link]
{
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 << "--------------------------------";
cout << endl;
cout << "Users defined value of Longitude :- " << endl;
Longitude.obtain_angle();
cout << endl;
Longitude.display_angle_of_Longitude();
cout << "--------------------------------";
cout << endl;
cout << "Users defined value of Latitude :- " << endl;
Latitude.obtain_angle();
cout << endl;
Latitude.display_angle_of_Latitude();
cout << "--------------------------------";
int z;
cout << "\nLoop Body :- \n";
cout << "How many times you want to run Loop ? : ";
cin >> z;
for (int i = 0; i < z; i++)
{
cout << "\nLoop Number : " << i + 1 << endl;
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();
cout << "--------------------------------";
}
_getch();
return 0;
This study source was downloaded by 100000822375251 from [Link] on 03-19-2022 15:32:58 GMT -05:00
[Link]
}
#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 [Link] on 03-19-2022 15:32:58 GMT -05:00
[Link]
cout << endl;
[Link]();
cout << endl;
legi.obtain_angle();
cout << endl;
[Link]();
_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 [Link] on 03-19-2022 15:32:58 GMT -05:00
[Link]
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 [Link] on 03-19-2022 15:32:58 GMT -05:00
[Link]
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();
};
void ship:: ship_position()
{
count++;
ship_number = count;
cout << "Enter direction on longitude : " << endl;
Longitude.obtain_data();
cout << endl;
cout << "Enter direction on latitude : " << endl;
Latitude.obtain_data();
}
void ship:: display()
{
cout << endl;
cout << "Direction of ship number " << ship_number << " is :- " << endl;
Longitude.display_angle_of_Longitude();
Latitude.display_angle_of_Latitude();
}
int ship::count = 0;
int main()
{
ship ship_1, ship_2, ship_3;
cout << "Direction of Ship number 1 :- \n" << endl ;
ship_1.ship_position();
ship_1.display();
cout << "-------------------------\n";
cout << endl;
cout << "Direction of Ship number 2 :- \n" << endl;
ship_2.ship_position();
ship_2.display();
cout << "-------------------------\n";
cout << endl;
cout << "Direction of Ship number 3 :- \n" << endl;
ship_3.ship_position();
ship_3.display();
cout << "-------------------------\n";
This study source was downloaded by 100000822375251 from [Link] on 03-19-2022 15:32:58 GMT -05:00
[Link]
cout << endl;
_getch();
return 0;
}
This study source was downloaded by 100000822375251 from [Link] on 03-19-2022 15:32:58 GMT -05:00
[Link]
Powered by TCPDF ([Link])