In C++, Please help me compute the following flowchart exactly like this requirement:
Concepts tested in this project
Project Description
Write a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".
Project Specifications
Input for this project:
Input Validation:
Output: The program should display the following data:
Processing Requirements
Summary :
Following are provided :
1) Code , (2) FLowchart for main and (3) output of program along with the file .
Note : implemented error handling for all fields .
##################### Code ###################
#include <fstream>
#include <iostream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <iomanip>
using namespace std;
int numOfEmployees();
double averageAbsent(int, int);
int totDaysAbsent(int, std::ofstream&);
int main()
{
std::ofstream outfile;
outfile.open("employeesAbsences.txt");
outfile << " Student : " << " XYZ
\n";
outfile << std::setw(12) << "EmployeeID "
<< std::setw(14) << " No of Leaves \n";
int tEmployees = numOfEmployees();
int tLeaves = totDaysAbsent(tEmployees,
outfile);
double avgleaves = averageAbsent(tEmployees,
tLeaves);
outfile << "Average Leaves : " <<
avgleaves << "\n";
outfile.close();
}
int numOfEmployees() {
int num_employees = -1;
bool flag = true;
std::string istr;
char a;
while (flag) {
std::cout << "Enter number of
employees : ";
try {
std::cin
>> istr;
num_employees =
std::stoi(istr);
if
(num_employees > 0)
flag = false;
else
std::cout << "Invalid input , try again
...\n";
}
catch (std::invalid_argument
const& e) {
std::cout
<< "Invalid Input, try again ... \n";
}
}
return num_employees;
}
int totDaysAbsent(int num, std::ofstream &outf) {
bool flag = false;
int total_leaves = 0;
std::string idstr;
std::string lstr;
int id;
int leaves;
for (int i = 0; i < num; i++) {
flag = true;
idstr.clear();
lstr.clear();
while (flag) {
std::cout
<< "Enter Employee ID : ";
try {
std::cin >> idstr;
id = stoi(idstr);
if (id > 0)
flag = false;
else
std::cout << "Invalid
input , try again ...\n";
}
catch
(std::invalid_argument const& e) {
std::cout << "Invalid Input, try again ...
\n";
}
}
flag = true;
while (flag) {
std::cout
<< "Enter Total Number of Leaves in the Year for Employee - "
<< id << " : ";
try {
std::cin >> lstr;
leaves = stoi(lstr);
if (leaves > 0)
flag = false;
else
std::cout << "Invalid
input , try again ...\n";
}
catch
(std::invalid_argument const& e) {
std::cout << "Invalid Input, try again ...
\n";
}
}
total_leaves = total_leaves +
leaves;
outf << std::setw(8)<<
id << " , " << std::setw(10) << leaves <<
"\n";
}
return total_leaves;
}
double averageAbsent(int totalEmployees, int totalLeaves) {
return (double)totalLeaves / totalEmployees;
}
###################### End Code ################
FLow chart :
Output :
In C++, Please help me compute the following flowchart exactly like this requirement: Use while loops...
Project DescriptionWrite a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".Project SpecificationsInput for this project:the user must enter the number of employees in the company.the user must enter as integers for each employee:the employee number (ID)the number of days that employee missed during the past year.Input Validation:Do not accept a number less than 1 for the number of employees.Do not accept a negative...
Kindly solve this using C PROGRAMMING ONLY. 4. Write a program marks.c which consists of a main function and three other functions called. readmarks , changemarks (, and writemarks() The program begins by calling the function readmarks () to read the input file marksin. txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks () the...
PROGRAM DESCRIPTIONIn this project, you have to write a C++ program to keep track of grades of students using structures and files.You are provided a data file named student.dat. Open the file to view it. Keep a backup of this file all the time since you will be editing this file in the program and may lose the content.The file has multiple rows—each row represents a student. The data items are in order: last name, first name including any middle...
in c++ please HW09: Read/Write File Ints Now that we've had a taste of what file I/O is all about, here's your chance to try it out on your own! You're to write a program that will prompt the user if he/she would like to read ints from a file (and have them displayed to stdout) or write ints to a file for safekeeping. If the user wishes to save a set of numbers, then the file nums.txt is opened...
Student ID: 123 Write a C+ program with the following specifications: a. Define a C++ function (name it function_StudentlD where StudentID is your actual student ID number) that has one integer input (N) and one double input (x) and returns a double output S, where N S = n 0 and X2 is given by 0 xeVn n 0,1 Хл —{2. nx 2 n 2 2 m2 x2 3 (Note: in the actual quiz, do not expect a always, practice...
using c++ output format should look this but use employee id,hours worked and pay rate and the total should be calculated. for example employee id:1234 hours work:29.3 pay rate:16.25 administrative, office and field should be outputted as well too. Using a structure, and creating three structure variables, write a program that will calculate the total pay for thirty (30) employees. (Ten for each structured variable.) Sort the list of employees by the employee ID in ascending order and display their...
create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...
use JOptionPane to display output Can someone please help write a program in Java using loops, not HashMap Test 1 Grades After the class complete the first exam, I saved all of the grades in a text file called test1.txt. Your job is to do some analysis on the grades for me. Input: There will not be any input for this program. This is called a batch program because there will be no user interaction other than to run the program....
I NEED A PSEUDOCODE ALGORITHM FOR THIS CODE PLEASE C++: #include #include #include #include using namespace std; int NumOfEmployees(); int TotDaysAbsent(int); double AverageAbsent(int, int); int main() { cout << endl << "Calculate the average number of days a company's employees are absent." << endl << endl; int numOfEmployees = NumOfEmployees(); TotDaysAbsent(numOfEmployees); return 0; } int NumOfEmployees() { int numOfEmployees = 0; cout << "Please enter the number of employees in the company: "; cin >> numOfEmployees; while(numOfEmployees <= 0) { ...