Menu

Wednesday, 26 November 2014

Chapter 6,Problem 7:Object Oriented Programming by Robert Lafore in C++ Solution Manual

//Engr. Ahmad Furqan Attari
//Chapter 6, Problem 7
#include <iostream>
#include <conio.h>
using namespace std;
class angle
{
private:
 int deg;
 float min;
 char dir;
public:
 angle()
 {}
 angle(int d , float m , char di): deg(d),min(m),dir(di)
 {}
 void get(void)
 {
  cout<<"Enter degree: ";
  cin>>deg;
  cout<<"Enter minute: ";
  cin>>min;
  cout<<"Enter direction: ";
  cin>>dir;
 }
 void show(void)
 {
  cout<<deg<<"\xF8"<<min<<"' "<<dir;
 }
};
void main(void)
{
 angle a(23,57,'E'),b;
 a.show();
 char ch;
 do
 {
  cout<<endl<<"Enter an angle "<<endl;
  b.get();
  cout<<"You entered: ";
  b.show();
  cout<<endl<<"Enter again? ";
  ch=getche();
 }while(ch!='n');
}

No comments:

Post a Comment