Program to generate report card of a student using functions like setw and gotoxy

This is a c++ program that will take input of employees datails such as name, number and salary. Using switch case this will generate a report card of the student in tabular form. In this program we will learn about a new function "setw()" due to this a new header file is also introduced that is "process.h". this could teach one a good concept of how to create a report card of a student with proper arrangment. Without disscusing much lets work on the program, the program comes as follows:
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<iomanip.h>
class employee
{
int eno;
char name[30];
float salary;
public :
void input()
{
cout << "Enter Employee Number ";
cin >>eno;
cout << "Enter name ";
gets(name);
cout << "Enter salary ";
cin >>salary;
}
void show()
{
cout << eno << setw(20)<<name<<setw(20)<<salary<<endl;
}
float rt_sal()
{
return salary;
}
}emp[10];
main()
{
int n,ch,i,j;
char choice;
do
{
clrscr();
cout << "1. For enter "<<endl;
cout << "2. For tabular report"<<endl;
cout << "3. For exit";
cin >> ch;
switch(ch)
{
case 1: cout << "Enter how many employees ";
cin >>n;
for(i=0;i<n;i++)
{
emp[i].input();
}

break;
case 2:
employee temp;
for (i=0;i<n;i++)
{
for(j=i;j<n-1;j++)
{
if (emp[j].rt_sal()>emp[j+1].rt_sal())
{
temp = emp[j];
emp[j]=emp[j+1];
emp[j+1]=temp;
}
}
}
gotoxy(6,6);
cout <<"Employee Number ";
gotoxy(26,6);
cout <<"Name";
gotoxy(46,6);
cout <<"Salary"<<endl;
int r = 8;
for(i=0;i<n;i++)
{
emp[i].show();
r++;
}

break;
case 3: exit(0);

}
cout << "\n Do U want to continue";
cin>>choice;
}while(choice == 'Y' ||choice =='y');

}

Share this

Related Posts

Previous
« Prev Post

1 comments:

Write comments
Anonymous
2 February 2022 at 02:10 delete

LuckyClub | Casino site | Lucky Club
LuckyClub is a UK online casino that's based out of Merseyside in the United Kingdom and is operated by the RGS Entertainment Group. The luckyclub.live site boasts a

Reply
avatar