Monday, December 23, 2019

Highest To Lowest Salary in C++ Language

I wrote this program to sort the name and salary of the employees from highest to lowest using C++ programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.
My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com
My programming website is http://www.jakerpomperada.blogspot.com



Sample Program Output


Program Listing

salary.cpp

//  salary.cpp
//   Author : Jake R. Pomperada,MAED-IT
//   December 22, 2019    10:09 AM
//   Monday
//   Bacolod City, Negros Occidental Philippines 
//   www.jakerpomperada.com
//   jakerpomperada@gmail.com

#include <iostream>
#include <iomanip>

using namespace std;

struct employee
{
    double salary ;
    char emp_name[200];
}emp_records[200],t;

int main()
{
    int i=0,j=0,n=0;
    cout <<"\n\n";
    cout <<"\tHighest To Lowest Salary in C++ Language";
    cout <<"\n\n";
    cout <<"\tHow many employees? : ";
    cin >> n;
   
    for(i=0;i<n;i++)
    {
         cin.ignore();
         cout <<"\tGive Employees Name   : ";
         cin.getline(emp_records[i].emp_name,100);
        
       
         cout <<"\tGive Employees Salary : ";
         cin >>emp_records[i].salary;
    }
    
    for(i=0;i<n;i++)
    {
        for(j=0;j<n-1;j++)
        {
            if(emp_records[j].salary<emp_records[j+1].salary)
            {
                t=emp_records[j];
                emp_records[j]=emp_records[j+1];
                emp_records[j+1]=t;
            }
        }
    }
    cout<<"\n\n";
    cout <<"\tEmployees that has the Highest to Lowest Salary\n\n";
    cout <<setw(25)<<" EMPLOYEES NAME" <<setw(15)<<"SALARY\n";
    cout <<setw(20)<<"-------------------------------------------------\n\n";
    
    for(i=0;i<n;i++)
    {
       cout <<fixed;
   cout <<setw(25)<<emp_records[i].emp_name <<setw(12)<<"PHP "<<setprecision(2)
   <<emp_records[i].salary<<"\n""";
    }
    cout <<"\n\n";
    cout <<"\tEnd of Program";
    cout<<"\n\n";
}



No comments:

Post a Comment