Thursday, 20 July 2017

Movie Counter

#include<iostream.h>
#include<conio.h>
class movcount
{ private:
   int tp;
   int tpass;
   long tamount;
   int tticket;
  public:
   void counter();
   void showdetail();

};
void movcount::counter()
{ char x;
  int count=0,pass=0;
  long amount=0;
  cout<<"Enter 't' ( with ticket ) \n 'p' ( with pass ) \n Or any other key to Calculate ";
  start:
  cin>>x;
  if (x=='t'||x=='p')
     { if (x=='t')
   { amount=amount+250;
     count++;
   }
       else if (x=='p')
   { count++;
     pass++;
   }
       goto start;
     }
  else
     { tamount=amount;
       tp=count;
       tpass=pass;
       tticket=count-pass;
     }
}
void movcount::showdetail()
{ cout<<"Total number of people visited = "<<tp<<"\n";
  cout<<"Total amount collected = "<<tamount<<"\n";
  cout<<"Total number of people with pass = "<<tpass<<"\n";
  cout<<"Total number of people with tickets ="<<tticket;
}
void main()
{ clrscr();
  movcount m1;
  m1.counter();
  m1.showdetail();
  getch();
}

0 comments:

Post a Comment