Sunday, 9 July 2017

Program for a "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();
}

No comments:

Post a Comment

Basic Implementation of Array as a Pointer

#include<iostream.h> #include<conio.h> void main() { clrscr();   int arr[5];   cout<<"Enter 5 nos. ";   f...