How do I do this and zip the file Create a program that disp
How do I do this and zip the file?
Solution
Below Code block implements a C++ program which takes N number of employees details and calculates their gross weekly salary based on the inputs like total number week hours and the rate per hour. The code is implemented using Class. Comments are provided in the code.
I will not be able to zip the file, so whole code is provided. Please copy and create the cpp file and execute
********************************************************
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#define SIZE 100
class Employee // Employee Class
{
int totalWeekHrs;
float ratePerHr;
float totalWeekSal;
char name[20],num[10];
public:
void getdata(); // function to get data from user
void calculateTotalSal(); // function to calculate gross weekly salary
void dispdata(); // function to display data
};
void Employee::getdata()
{
cout<<\"\ Enter employee number: \";
gets(num);
cout<<\" Enter employee name: \";
gets(name);
cout<<\"Enter employee total working hours in current week: \";
cin>>totalWeekHrs;
cout<<\"Enter employee rate per hour: \";
cin>>ratePerHr;
}
void Employee::calculateTotalSal()
{
int x;
float extraSal;
if(totalWeekHrs<=40)
{
totalWeekSal=totalWeekHrs*ratePerHr;
}
else
{
totalWeekSal=40*ratePerHr;
x= totalWeekHrs-40;
extraSal= x*(ratePerHr/2);
totalWeekSal+=extraSal;
}
}
void Employee::dispdata()
{
cout
<<\"\ Employee number: \"<<num
<<\"\ Employee name: \"<<name
<<\"\ total working hours in current week: \"<<totalWeekHrs
<<\"\ rate per Hour: \"<<ratePerHr<<\" $\"
<<\"\ Gross Weekly Salary: \"<<totalWeekSal<<\" $\";
}
void main()
{
clrscr();
Employee ob[SIZE]; // array of Employees
int n;
cout<<\"\ \ ********************************************\"
<<\"\ Calculation of Employee Gross Weekly Salary\"
<<\"\ **********************************************\"
<<\"\ Enter the number of employees: \";
cin>>n;
for(int i=0;i<n;i++)
{
ob[i].getdata();
ob[i].calculateTotalSal();
}
clrscr();
cout<<\"\ -----------------\"
<<\"\ Employee Detail::\"
<<\"\ -----------------\";
for( i=0;i<n;i++)
{
cout<<\"\ \ Employee:\"<<i+1
<<\"\ ----------\";
ob[i].dispdata();
}
getch();
}

