Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help. please write in c programming Power programming 93 due Nov. 19, 201

ID: 3763448 • Letter: P

Question

please help. please write in c programming



Power programming 93 due Nov. 19, 201S 2:00pm Write a c program that inputs (at most 50) records from a sequential file and stores them in order by lastname in a linked list Use the following structure definition in your program Write a c program to create the report below (records sorted by last name) and write the output formatted in the manner shown in the example below to an output file. Compute and print the student age to the nearest year old. struct stu data I char last name [15) char first mame 15] int b month int b day int b-year float annual salary char dept code char phone_numberl12)

Explanation / Answer

#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
#include <string.h>

struct date
{
int year,month,day;
};

struct person
{
int recno;
char Last_name [20];
char first_name [20];
date dob;
int dept_code;
int age;
int salary;
};

void line(void);    //Global Declaration of function as it is called in another function other than main.void main()
{
void starting(void);
void sorting(struct person[],int);
void display(struct person[]);
void end(void);
person rec[5];            //Declaration of person datatype

starting();

textcolor(111);
textbackground(196);
clrscr();
cout<<" "<<setw(48)<<"RECORD INFORMATION";
//for inserting records
cout<<" Enter 5 Records ";
for(int i=0,c=1;i<5;i++)
{

    cout<<"Information for Record No. "<<c<<endl;
    c++;
    line();
    cout<<" Enter Record Number:-";
   cin>>rec[i].recno;
   cout<<"Enter first Name :-";
   cin>>rec[i].first_name ;
    cout<<"Enter Name :-";
   cin>>rec[i].Last_name ;
   cout<<" FOR Birth_Date ";
   cout<<"-------------- ";
   cout<<"Enter Year:-";
   cin>>rec[i].dob.year;
   cout<<"Enter Month:-";
   cin>>rec[i].dob.month;
   cout<<"Enter Day:-";
   cin>>rec[i].dob.day;
   cout<<" Enter salary:-";
   cin>>rec[i].salary;
   cout<<" Enter age:-";
   cin>>rec[i].age;
   cout<<" Enter dept code:-";
   cin>>rec[i].dept_code;
   line();
   cout<<endl<<endl;
}

clrscr();
display(rec);
clrscr();
cout<<endl<<endl;
int choice;
do
{
cout<<endl<<endl;
cout<<" What Operation Would you Like to Perform ";
cout<<"1)    sort by last name ";
cout<<"2)    DISPLAYING ";
cout<<"3)    QUIT ";
cout<<"Enter Your Choice:-";
cin>>choice;
    switch(choice)
    {

   case    1:sorting(rec,choice);
                break;
    case     2:display(rec);
            break;
   case    3:gotoout;
    default:cout<<"Entered Choice is Invalid, Try Again";
    }
   getch();
   clrscr();
}while(1);
out:
}

   //Last_name wise sorting
   if(choice==1)
   {
    for(int i=0;i<5;i++)
      {
    for(int j=i+1;j<5;j++)
     {
        if(strcmp(rec[i].Last_name ,rec[j].Last_name )>0)
        {
           tempq                  = rec[i];
           rec[i]                = rec[j];
           rec[j]              = tempq;
           }
     }
      }
    }

//display function
void display(struct person rec[])
{
textcolor(106);
textbackground(104);
clrscr();
cout<<endl<<endl<<endl;
line();
cout<<setw(10)<<"first_name"<<setw(25)<<"Last_name"<<setw(20)<<"DATE OF BIRTH"<<setw(23)<<"SALARY AT PRESENT"<<<<"Dept_code"<<setw(25)<<"Age"<<setw(20)endl;
line();
for(int i=0;i<5;i++)
{
cout<<endl;
cout<<setw(6)<<rec[i].first_name;
cout<<setw(27)<<rec[i].Last_name ;
cout<<setw(15)<<rec[i].dob.day<<"\"<<rec[i].dob.month<<"\"<<rec[i].dob.year;
cout<<setw(15)<<rec[i].salary;
cout<<setw(15)<<rec[i].age;
cout<<setw(15)<<rec[i].dept_code;
cout<<endl;
}
getch();
}


//Line function
void line(void)
{
    for(int i=0;i<40;i++)
    {
        cout<<"--";
    }
   cout<<endl;
}


void starting(void)
{
textcolor(105);
textbackground(104);
clrscr();
cout<<endl;
cout<<"|";
for(int i=0;i<39;i++)
{
        cout<<"--";
}
cout<<"|";

cout<<"";
for(int j=0;j<32;j++)
    cout<<"=";

cout<<"Syntax-Example";

for(int k=0;k<33;k++)
    cout<<"=";

cout<<endl;

cout<<"|";
for(int p=0;p<39;p++)
{
        cout<<"--";
}
cout<<"|";
cout<<endl<<endl<<endl;
line();
cout<<setw(79)<<"Created for Synatx-Example site. ";

getch();

}