0% found this document useful (0 votes)
32 views

Sample Program Implementation File I

This document contains the code for a student management system with functions to get student data, display all students, display a specific student, bill all students, bill a specific student, view students by gender, view students with balance below an amount, calculate total balance, and a main function to call these functions based on user input. The code defines a student struct, declares an array of students, and includes a header file containing function declarations.

Uploaded by

sanicyril7
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views

Sample Program Implementation File I

This document contains the code for a student management system with functions to get student data, display all students, display a specific student, bill all students, bill a specific student, view students by gender, view students with balance below an amount, calculate total balance, and a main function to call these functions based on user input. The code defines a student struct, declares an array of students, and includes a header file containing function declarations.

Uploaded by

sanicyril7
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

Sample program implementation file I,e .h file call student data.

#include<iostream>
#include<string>
#define n 3
using namespace std;

struct student
{
string regno;
string fname;
string gender;
float fbal;
};

student bsc[n];
int i;
float total=0;
bool studentExist(string reg);
void displaySpecificstudent(string );
void getdata()
{
for(i=0;i<n;i++)
{
cout<<"Student registration \n";
cout<<"=========================================\n";
cout<<" Register student NO "<<i+1<<endl;
cout<<"=========================================\n";
cout<<"Enter registration : " ;
cin>>bsc[i].regno;
cout<<"Enter Full name: " ;
cin>>bsc[i].fname;
cout<<"Enter student Gender :" ;
cin>>bsc[i].gender;
cout<<"Enter Initial fees balance :" ;
cin>>bsc[i].fbal;
cout<<"=========================================\n";
}
}
void displayAll()
{
cout<<"RegNo Full Name Gender Feess balance\n";
cout<<"-------------------------------------------\n";
for(i=0;i<n;i++)
{
cout<<bsc[i].regno<<" \t "<<bsc[i].fname<<" "<<bsc[i].gender<<"
\t "<<bsc[i].fbal<<endl;
}
}
void billAstudent(string regno)
{
bool exist;
float amt;
exist=studentExist(regno);

if(exist==true)
{
cout<<"Enter Bill amount for student :";
cin>>amt;
for(i=0;i<n;i++)
{
if(regno==bsc[i].regno )bsc[i].fbal=bsc[i].fbal+amt;

}
}
else
{
cout<<" student not registered";
}

}
bool studentExist(string reg)
{
bool status;

for(i=0;i<n;i++)
{
if(bsc[i].regno==reg)
{
displaySpecificstudent(reg);
status= true;
}
else
{
cout<<" no such student\n";
status=false;
}
}
return status;
}
void viewbygender(string gd)
{
cout<<"RegNo Full Name Gender \n";
cout<<"-------------------------------------------\n";
for(i=0;i<n;i++)
{
if(gd==bsc[i].gender )
{
cout<<bsc[i].regno<<" \t "<<bsc[i].fname<<"
"<<bsc[i].gender<<endl;
}

}
}
void balancebelow(float reg)
{
cout<<"RegNo Full Name Gender Feess balance\n";
cout<<"-------------------------------------------\n";
for(i=0;i<n;i++)
{
if(bsc[i].fbal >= reg)
{
cout<<bsc[i].regno<<" \t "<<bsc[i].fname<<" \t
"<<bsc[i].fbal<<endl;
}

}
}
void displaySpecificstudent(string reg)
{
cout<<"RegNo Full Name Gender Feess balance\n";
cout<<"-------------------------------------------\n";
for(i=0;i<n;i++)
{
if(reg==bsc[i].regno)
{
cout<<bsc[i].regno<<" \t "<<bsc[i].fname<<" "<<bsc[i].gender<<"
\t "<<bsc[i].fbal<<endl;
}

}
}
void invoiceAllstudent(float amt)
{
for(i=0;i<n;i++)
{
bsc[i].fbal=bsc[i].fbal+amt;
}
}
float totalbal()
{

for(i=0;i<n;i++)
{
total=total+bsc[i].fbal;
}
return total;
}

Sample program application file I,e .cpp file


#include<iostream>
#include<string>
#include "studentdata.h"
#define n 2
using namespace std;

int main()
{

getdata();
int x;
do
{
cout<<"This program can do the following\n";
cout<<"----------------------------------\n";
cout<<"\t\t 1 View All students\n";
cout<<"\t\t2 View specific student\n";
cout<<"\t\t 3 Bill all students \n";
cout<<"\t\t 4 Bill specific student \n";
cout<<"\t\t 5 View student by Gender\n";
cout<<"\t\t 6 Fees balance below kshs :\n";
cout<<" \t\t7. total balance \n";
cout<<"\t\t 8 . Exit\n";
cout<<"----------------------------------\n";
cout<<" Enter your choice :";
cin>>x;
cout<<"----------------------------------\n";
switch(x)
{
case 1:
{
displayAll();
};break;
case 2:
{
string sreg;
cout<<"Enter student to locate :";
cin>>sreg;
displaySpecificstudent(sreg);
};break;
case 3:
{
float amt;
cout<<"Enter invoice amount :";
cin>>amt;
invoiceAllstudent(amt);
};break;
case 4:
{
cin.ignore();
string sreg;

cout<<"Enter students' Regno to locate :";


cin>>sreg;
billAstudent(sreg);
};break;
case 5:
{
string g;
cout<<"Enter Student gender to displays :";
cin>>g;
viewbygender(g);
};break;
case 6:
{
float amt;
cout<<"Student with fees balance Above
kshs :";
cin>>amt;
balancebelow(amt);
};break;
case 7:
{
cout<<" fees Balance total is kshs "
<<totalbal()<<endl;
}
case 8:
{
break;
};break;
}
}while(x!=8);
return 0;
}

You might also like