An angle may be measured in degrees and minutes.
Eg: ∠a=70 degrees 35 mins, ∠b=50 degrees 40 mins
sum of angles c is ∠c=∠a + ∠b = 121 degrees 15 mins (Since 1 degree = 60 mins)
Create a class called 'angle' with the following details
instance variables
int deg, int min - to store degrees and minutes of an angle
methods
void enterangles() -to input an angle
angle sumangle(angle a,angle b) -to find sum of the angles and display it.
void display() - to display the degrees and minutes of an angle
WAP in BlueJ using the above class to accept 2 angles and find their sum and display it.
Answers
Answered by
2
In c++ :-
#include<iostream.h>
#include<conio.h>
class angle
{
int deg;
int min;
public:
angle();
angle(int,int);
void enterangles();
angle sumangle(angle,angle);
void display ();
};
angle()
{
deg=0;
min=0;
}
angle(int d,int m)
{
deg=d;
min=m;
}
void angle:: enterangles ()
{
cout<<"enter degree:";
cin>>deg;
cout<<"enter min";
cin>>min;
}
angle angle:: sumangle(angle a,angle b)
{
int deg;
int min;
deg=a.deg+b.deg;
min=a.min+b.min;
if(min>60)
{
min- = 60;
}
deg++;
return angle (deg,min);
}
void angle::display()
{
cout<<"degree="<<deg;
cout<<"minute="<<min;
}
void main()
{
clrscr();
angle a,b,sum;
a.enterangles();
b.enterangles();
sum.sumangle(a,b);
sum.display();
getch();
}
Feeling good, to help you guys !!
Similar questions
Accountancy,
5 months ago
Math,
5 months ago
Math,
10 months ago
English,
10 months ago
Biology,
1 year ago