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)
{
cout << endl << "The number of employees must not be 0 or negative.\nPlease re-enter the number of employees: ";
cin >> numOfEmployees;
}
return numOfEmployees;
}
int TotDaysAbsent(int numOfEmployees)
{
int totalDaysAbsent = 0;
int employeeId[numOfEmployees];
int daysAbsent[numOfEmployees];
string programmerName = "";
for(int i = 0; i < numOfEmployees; i++
{
int empId = 0;
int absentDays = 0;
cout << "Please enter an employee id: ";
cin >> empId;
employeeId[i] = empId;
cout << "Please enter the number of days this employee was absent: ";
cin >> absentDays;
while(absentDays < 0)
{
cout << endl << "The number of days must not be negative.\nPlease re-enter the number of days absent: ";
cin >> absentDays;
}
daysAbsent[i] = absentDays;
}
cout << "Programmer: ";
cin.sync();
cin >> programmerName;
//getline(cin, programmerName, '\n');
// write to file
ofstream outputFile("employeeAbsences.txt");
if(!outputFile.is_open())
cout << "Unable to open employeeAbsences.txt file!" << endl;
else
{
outputFile << "EMPLOYEE ABSENCE REPORT" << endl;
outputFile << "Employee Id\t\tDays Absent" << endl;
for(int i = 0; i < numOfEmployees; i++)
{
outputFile << employeeId[i] << "\t\t\t\t\t" << daysAbsent[i] << endl;
totalDaysAbsent += daysAbsent[i];
}
outputFile << endl << "The " << numOfEmployees << " employees were absent for a total of " << totalDaysAbsent << " days." << endl;
outputFile << "The average number of days absent is " << setprecision(1) << fixed << AverageAbsent(numOfEmployees, totalDaysAbsent) << " days." << endl;
outputFile << endl << "Programmer: " << programmerName << endl;
outputFile.close();
}
return totalDaysAbsent;
}
double AverageAbsent(int numOfEmployees, int totalDaysAbsent)
{
return (double)(totalDaysAbsent / numOfEmployees);
}
START
METHOD Main
PRINT "Calculate the average number
of days a company's employees are absent"
GET numOfEmployees = CALL
NumOfEmployees() Method
CALL
TotDaysAbsent(numOfEmployees)
METHOD NumOfEmployees ()
DECLARE numOfEmployees to 0
GET numOfEmployees from USER
WHILE (numOfEmployees is <
0)
PRINT "Must not
be 0, enter again: "
GET
numOfEmployees from USER
RETURN GET numOfEmployees
METHOD TotDaysAbsent (numOfEmployees)
DECLARE totalDaysAbsent = 0
DECLARE
employeeId[numOfEmployees]
DECLARE
daysAbsent[numOfEmployees]
DECLARE programmerName
LOOP FOR i = 0 down to
numOfEmployees
GET empID and
absentDay
Validate INPUTs
taken above
employeeId[i] =
empID
daysAbsent[i] =
absentDay
GET programmerName from the
user
OPEN FILE
"employeeAbsences.txt"
LOOP FOR i = 0 down to
numOfEmployees
APPEND
employeeId[numOfEmployees] into FILE
APPEND
daysAbsent[numOfEmployees] into FILE
UPDATE
totalDaysAbsent = totalDaysAbsent + daysAbsent[i]
WRITE to FILE numOfEmployees +
totalDaysAbsent
WRITE to FILE
AverageAbsent(numOfEmployees, totalDaysAbsent)
WRITE to File programmerName
RETURN totalDaysAbsent
METHOD AverageAbsent (numOfEmployees,
totalDaysAbsent)
RETURN totalDaysAbsent /
numOfEmployees
END

I NEED A PSEUDOCODE ALGORITHM FOR THIS CODE PLEASE C++: #include #include #include #include using...
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) {...
I need a detailed pseudocode for this code in C ++. Thank you #include <iostream> #include <string> #include <iomanip> using namespace std; struct Drink { string name; double cost; int noOfDrinks; }; void displayMenu(Drink drinks[], int n); int main() { const int size = 5; Drink drinks[size] = { {"Cola", 0.65, 2}, {"Root Beer", 0.70, 1}, {"Grape Soda", 0.75, 5}, {"Lemon-Lime", 0.85, 20}, {"Water", 0.90, 20} }; cout <<...
Using the code below (C++), add a struct with only 1 vector #include #include #include // Needed to define vectors using namespace std; int main() { vector hours; // hours is an empty vector vector payRate; // payRate is an empty vector int numEmployees; // The number of employees int index; // Loop counter // Get the number of employees. cout << "How many employees do you have? "; cin >> numEmployees; // Input the payroll data. cout << "Enter...
i am having trouble displaying results and displaying them evenly it is suppose to look like this Enter the following data for employee 1: Employee ID: 1298 Hours worked: 35.8 Pay rate (per hour): 23.45 Enter the following data for employee 2: Employee ID: 1899 Hours worked: 34.5 Pay rate (per hour): 19.5 Enter the following data for employee 3: Employee ID: 4435 Hours worked: 30.5 Pay rate (per hour): 20.75 Enter the following data for employee 4: Employee ID:...
How do can I update this code (Code A): Code (A) #include using namespace std; int fibonacci(int n) { int a = 0, b = 1, c; if (n <= 1) return n; for (int i = 2; i <= n; i++) { c = a + b; a = b; b = c; } return b; } int fibonacciRecursive(int n) { if (n <= 1) { return n; } return fibonacciRecursive(n-1) + fibonacciRecursive(n-2); } int main() { int n;...
c++ programming : everything is done, except when you enter ("a" ) in "F" option , it does not work. here is the program. #include <iostream> #include <string> #include <bits/stdc++.h> #include <iomanip> #include <fstream> using namespace std; #define MAX 1000 class Inventory { private: long itemId; string itemName; int numberOfItems; double buyingPrice; double sellingPrice; double storageFees; public: void setItemId(long id) { itemId = id; } long getItemId() { return itemId; } void setItemName(string name) { itemName = name; } string...
The following C++ code include 3 files: Patient.h, Patient.cpp and Main.cpp. The program basically creates and stores patient records. The original code has everything in a single .cpp file. I tried to divide the code in 3 parts (Patient.h, Patient.cpp and Main.cpp), but it is giving me errors. Patient.h #ifndef PATIENT_H #define PATIENT_H #include <string> #include "Patient.cpp" using namespace std; class Patient{ private : string firstname; string lastname; string location; static int cnt; int id; public : Patient(string, string, string);...
Write a Pseudocode for the below implementation of Greedy Algorithm to find the number of the least truck can be used to deliver items in C++. #include <iostream> using namespace std; void TruckFunction(int n , int w[], int limit) { int trucks = 1; int weight = 0; cout<<endl<<"Items carried in truck " <<trucks<<": "<<endl; for ( int i = 0 ; i < n ; i ++ ) { if((weight + w[i]) <= limit) { weight += w[i]; cout<<"Item...
Hello, I have written a code that I now need to make changes so that arrays are transferred to the functions as pointer variable. Below is my code I already have. #include<iostream> #include<string> #include<iomanip> using namespace std; //functions prototypes void getData(string id[], int correct[], int NUM_STUDENT); void calculate(int correct[], int incorrect[], int score[], int NUM_STUDENT); double average(int score[], int NUM_STUDENT); void Display(string id[], int correct[], int incorrect[], int score[], double average, int NUM_STUDENT); int findHigh(string id[], int score[], int NUM_STUDENT);...
#include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...