The following needs to be in C programming !
Outcomes:
Program Specifications:
DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items:
The program will reuse the DATE struct from the previous assignment. You should also copy in the functions relating to a DATE.
The program will create a PAYRECORD struct with the following fields:
typedef struct {
char name[100];
int age;
float hrlyWage;
float hrsWorked;
float regPay;
float otPay;
float totalPay;
DATE payDate;
} PAYRECORD;
Requirements:
Bonus:
You will receive a 25-point bonus if your program stores all payroll data in a file and loads in stored payroll data from that file.
Outcomes:
Program Specifications:
DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items:
The program will reuse the DATE struct from the previous assignment. You should also copy in the functions relating to a DATE.
The program will create a PAYRECORD struct with the following fields:
typedef struct {
char name[100];
int age;
float hrlyWage;
float hrsWorked;
float regPay;
float otPay;
float totalPay;
DATE payDate;
} PAYRECORD;
Requirements:
Bonus:
You will receive a 25-point bonus if your program stores all payroll data in a file and loads in stored payroll data from that file.
Code :
#define _CRT_SECURE_NO_WARNINGS
#include <stdlib.h>
#include <stdio.h>
#define PAUSE //system("pause");
#define CLS //system("cls");
#define FLUSH //fflush(stdin);
#define MAX 100
struct namerecord {
char first[25];
char last[25];
};
struct DATE {
int day;
int month;
int year;
};
struct payrecord {
int id;
struct namerecord name;
int age;
float hoursWorked;
float hourlyRate;
float regularPay;
float overtimePay;
float gross;
struct DATE date;
};
typedef struct payrecord payrecord;
int getRecords(FILE *fp,payrecord payroll[],int max);
int getSelection();
double calcPayroll(payrecord payroll[], int n);
void printAllRecords(FILE *fp,payrecord payroll[], int n);
void getName(payrecord payroll[], int i);
void grossPayroll(payrecord payroll[], int i);
void printGrossPayroll(double gross);
void displayMenu();
void getdate(payrecord payroll[], int i);
int main()
{
FILE *fp;
int userSelection;
int i = 0, n = 0, numOfEmployees = 0;
double gross = 0, tax = 0;
payrecord payroll[MAX];
do
{
userSelection = getSelection();
switch (userSelection)
{
case 1:
CLS;
// Get the employee information from the user
fp = fopen("abc.txt","w");
n = getRecords(fp,payroll, numOfEmployees);
numOfEmployees++;
PAUSE;
fclose(fp);
break;
case 2:
CLS;
fp = fopen("abc.txt","r");
gross = calcPayroll(payroll, numOfEmployees);
printAllRecords(fp,payroll, numOfEmployees);
PAUSE;
fclose(fp);
break;
case 3:
CLS;
gross = calcPayroll(payroll, numOfEmployees);
printGrossPayroll(gross);
PAUSE;
break;
default:
PAUSE;
break;
}
} while (userSelection != 4);
fclose(fp);
return 0;
}
void displayMenu()
{
CLS;
printf("=========== PAYROLL PROGRAM ===========\n");
printf("=========== Menu ===========\n");
printf("1. Add an employee\n");
printf("2. Display ALL employees\n");
printf("3. Display GROSS Payroll\n");
printf("4. Quit\n");
printf("=======================================\n");
printf("Enter your selection: ");
} // end displayMenu()
int getSelection()
{
int result;
displayMenu();
scanf("%i", &result);
fflush(stdin);
return result;
} // end getSelection()
int getRecords(FILE *fp,payrecord payroll[], int max)
{
int i=max, j, n;
float z;
payrecord pay;
fflush(stdin);
// Ask the user for the employee name
void getName(payrecord payroll[], int i);
printf("ID Number: ");
j = scanf("%d%*c", &n);
// Error checking
if (j == EOF)
return i;
payroll[i].id = n;
getName(payroll, i);
getdate(payroll, i);
printf("Age: ");
j = scanf("%d%*c", &n);
payroll[i].age =n;
printf("Hours Worked: ");
j = scanf("%f%*c", &z);
payroll[i].hoursWorked = z;
printf("Hourly Rate: ");
j = scanf("%f%*c", &z);
payroll[i].hourlyRate = z;
grossPayroll(payroll,i);
fwrite(&payroll[i],sizeof(payroll[i]),1,fp);
return i;
}
void getName(payrecord payroll[], int i)
{
printf("First Name: ");
gets(payroll[i].name.first);
printf("Last Name: ");
gets(payroll[i].name.last);
}
void getdate(payrecord payroll[], int i)
{ int n,j;
printf("Day: ");
j = scanf("%d%*c", &n);
payroll[i].date.day = n;
printf("Month: ");
j = scanf("%d%*c", &n);
payroll[i].date.month = n;
printf("year: ");
j = scanf("%d%*c", &n);
payroll[i].date.year = n;
}
void grossPayroll(payrecord payroll[], int i)
{
if (payroll[i].hoursWorked <= 40)
{
payroll[i].regularPay = payroll[i].gross = payroll[i].hoursWorked *
payroll[i].hourlyRate;
payroll[i].overtimePay = 0;
}
else {
payroll[i].regularPay = 40 * payroll[i].hourlyRate;
payroll[i].overtimePay = (payroll[i].hoursWorked - 40) * 1.5 *
payroll[i].hourlyRate;
}
payroll[i].gross = payroll[i].regularPay +
payroll[i].overtimePay;
}
double calcPayroll(payrecord payroll[], int n)
{
int i;
double gross = 0;
printf("No of employees = %d\n",n);
for (i = 0; i < n; i++)
{
// Gross pay
gross = gross + payroll[i].gross;
}
return gross;
}
void printAllRecords(FILE *fp,payrecord payroll[], int n)
{ payrecord pay;
for (int i = 0; i < n; i++)
{ fread(&pay, sizeof(pay),1,fp);
printf("ID Number: %d\n", pay.id);
printf("Name: %s %s\n", pay.name.first, pay.name.last);
printf("Age : %d", pay.age);
printf("Hours Worked: %.2f\n", pay.hoursWorked);
printf("Overtime Pay: $%.2f\n", pay.overtimePay);
printf("Hourly Rate: $%.2f\n", pay.hourlyRate);
printf("Gross Pay: $%.2f\n",pay.gross);
printf("Date : %d / %d /
%d\n",pay.date.day,pay.date.month,pay.date.year );
}
}
void printGrossPayroll(double gross)
{
printf("==== TOTAL PAYROLL ====\n");
printf("Gross Employee Pay: $%.2f\n", gross);
}
Output:



The date format is not given so i provide a normal format.
The following needs to be in C programming ! Outcomes: Demonstrate the ability to design a...
Requesting help with the following C Program: DESIGN and IMPLEMENT a menu driven program that uses the following menu and can perform all menu items: Enter a payroll record for one person Display all paycheck stubs Display total gross payroll from all pay records. Quit program The program will reuse the DATE struct from the previous assignment. You should also copy in the functions relating to a DATE. The program will create a PAYRECORD struct with the following fields: typedef struct...
* C PROGRAMMING* Outcomes: Demonstrate the ability to create and use linked lists in dynamic memory Demonstrate the ability to add nodes and remove nodes from a linked list of structs Program Specifications: Write a program that creates the following struct (you can give it whatever name you want): char name[100]; int age; float weight; Create the following menu system: Add a Record Display All Records Quit When the user selects (1) you will prompt them for a name, age,...
*MUST BE IN C PROGRAMMING* Demonstrate the ability to think critically Demonstrate the ability to work with strings and chars Demonstrate the ability to design a menu system Write a simple program that allows the user to enter a number between 1 and 1000. The program will then display the Roman numeral equivalent. Allow the user to keep entering numbers for conversion to Roman numerals, or to quit, using a menu system of your own design. Submission Requirements: You are to write...
***************C PROGRAMMING ONLY************* Demonstrate the ability to create an array on the stack Demonstrate the ability to create an array on the heap allowing user to choose the number of values to store. Demonstrate the ability to store an array of Struct values on both the stack and the heap. Program Specifications: 1. Create a struct with at least 3 fields - any struct you want but explain it in your comments in the code. Populate at least 10 elements...
Methods and File Output and Exceptions Outcome: Student will demonstrate the ability to write, use and call methods Student will demonstrate the ability to pass values to and from methods Student will demonstrate the ability to catch exceptions Student will demonstrate the ability to create a text file Student will demonstrate the ability to validate input data Program Specifications: You to write a menu driven program. The program will use a switch statement. The cases will be as follows: Get...
Java Programing Code only Ragged Array Assignment Outcome: Student will demonstrate the ability to create and use a 2D array Student will demonstrate the ability to create and use a jagged array Student will demonstrate the ability to design a menu system Student will demonstrate the ability to think Program Specifications: Write a program that does the following: Uses a menu system Creates an array with less than 25 rows and greater than 5 rows and an unknown number of...
Why is my code not calculating the pay and not printing entire data at the end? // // main.cpp // Project 14 // // Created by Esmeralda Martinez on 5/13/19. // Copyright © 2019 Esmeralda Martinez. All rights reserved. // #include<iostream> #include<fstream> #include<cstdlib> #include<regex> #include <iomanip> using namespace std; float grossPay(float hrsWorked, float payrate); float grossPay(float hrsWorked, float payrate){ return hrsWorked*payrate; } int main(){ //opening an output file ifstream outFile("Employee.txt", ios::in); //Read variables string depId,emp_num,firstName,lastName,email,hrs_worked,pay_rate,ch="y"; //Regex patterns regex integerPattern("(\\+|-)?[[:digit:]]+"); regex...
java Payroll class Exceptions Programming Challenge 5 of Chapter 6 required you to write a Payroll class that calculates an employee’s payroll. Write exception classes for the following error conditions: • An empty string is given for the employee’s name. • An invalid value is given for the employee’s ID number. If you implemented this field as a string, then an empty string would be invalid. If you implemented this field as a numeric variable, then a negative number or...
Payroll Application Problem Description: An org needs a payroll application which has the capability to calculate and print the monthly pay of an employee. The application starts by printing a short description of what it does. Then, it asks for the employee name. Next, the application prompts for employee type (“H” for hourly and “S” for salaried.) If the user enters S, the gross pay is set to $4000. However, if the user enters H for an hourly employee, the...
Program 3. Decisions Due: Friday, February 7 by 11:59 PM Overview For this program, design a wage calculator for a single user. The program will use the user's number of hours worked and their hourly wage to calculate: Gross Pay Deduction Net Pay The Gross Pay is the amount that the user is paid before any deduction is applied. The pay amount is based upon the number of hours worked. If 40 hours or less were worked, the gross pay...