Google PlusFacebookTwitter

Classes – Admission Process

By on Apr 14, 2007 in On A Whim | 0 comments

Share On GoogleShare On FacebookShare On Twitter

/* Copyright (C) 2007 Ankur Banerjee. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. http://www.fsf.org/licensing/licenses/lgpl.html */

/* WAP to administer admission process. Define a class ‘admission’ with private members admno (int), name (string), classes (char), fee (float); public members functions readdata() to input data, disp() to display data, drawnos() to choose two students randomly. WARNING: The following program might take a long time to reach completion at the draw numbers stage – it is not an infinite loop problem but until two students are chosen the loop will keep on running, resulting in long program execution time. */

#include <iostream.h>
#include <stdio.h>
#include <stdlib.h>

int i, flag = 1;

class admission
{
int admno;
char name[50], classes; // variable name class cannot be used since it is a keyword
float fee;
public:
void readdata()
{
cout<<endl<<“Enter data for student “<<i + 1
<<endl<<“Enter admission number : “;
cin>>admno;
cout<<“Enter name of student : “;
gets(name);
cout<<“Enter section of student : “;
cin>>classes;
cout<<“Enter fees submitted by student : “;
cin>>fee;
}
void disp()
{
cout<<“Displaying data for student”<<endl
<<“Admission number : “<<admno<<endl
<<“Student name : “<<name<<endl
<<“Section : “<<classes;
}
void drawnum()
{
int n1;
randomize();
n1 = random(1991) + 10;
if (( n1 == admno) && (flag < 3))
{
disp();
flag++;
}
}
} s[5];

void main()
{
clrscr();
cout<<endl<<“Admission Process Management Program”<<endl
<<“Enter initial data for all students”<<endl;
for (i = 0; i < 5; i++)
s[5].readdata();
cout<<endl<<“Randomly choosing students for admission”<<endl;
do
{
for (i = 0; i < 5; i++)
s[i].drawnum();
} while (flag < 3);
cout<<endl<<“Two students have been chosen randomly out of database”<<
getch();
}



Submit a Comment

Your email address will not be published. Required fields are marked *