Question: Modify this C++ Program by adding the following: Change from one employee to n employees. Read the value of n from a keyboard (it should

Modify this C++ Program by adding the following:

Change from one employee to n employees. Read the value of n from a keyboard (it should be at least 3) and validate it using a while loop. Its value should be in the range of 1 and 5.

All the variables and names constants must be declared in the beginning of the program. Use named constants for storing the weights.

Read rest of the input from the Input File and validate all input data. Report should be based on three years evaluations. It means that you will be using a nested for loop. The outer loop will be on employees and the inner loop will be on years. You will be computing and writing in the report each years Final Weighted Evaluation, Total Final Weighted Evaluation (total of all three years), and Average Final Weighted Evaluation (average of all three years). Use the Average Final Weighted Evaluation (AFWE) to determine appreciation/warning letters as follows:

o If the AFWE is < 70, Report should include a warning letter (store the content of the letter in the Input File and read it from the Input File.)

o If the AFWE is >= 95, Report should include an appreciation letter (store the content of the letter in the Input File and read it from the Input File.))

Report should include current salary, salary raises (in % as well as in dollars), and salary with the raise. Use the Average Final Weighted Evaluation (AFWE) to determine the salary raise as follows:

o If the AFWE is < 75, Salary Raise = 0%

o If the AFWE is > 75 but < = 80, Salary Raise = 1%

o If the AFWE is > 80 but < = 90, Salary Raise = 3%

o If the AFWE is > 90 but < = 100, Salary Raise = 5%

o If the AFWE is > 100, Salary Raise = 10%

Since all the other data (except the value of n) is read from the input file, use if statements to validate the data. Strings should be validated for their lengths in the range of 1 to 50 (use length member function, to compute the string length); integer numbers should be between 1 and 100; and floating point numbers should be between 1.00 and 1000.00.

In the validation of the data, if the non-numerical data is not correct, print a statement about it and use continue statement to skip the current iteration. If numerical data is not correct, print the warning about this data and use break statement to terminate the loop.

Write all the Output to the Output File.

Create your own data in the input file (except the value of n which you are reading from the keyboard as described above) before running the program

A new sample Input/output for one employee is provided below. Your report will have at least three employees

INPUT

Name of the Employee: John Snow

Name of the Supervisor: Daenerys Targaryen

Employee ID #: A-5971-359182

Telephone Number: (745)784-5554

Address: 789 Alabama Street

Spring Semester Evaluation, 2015: 80.00

Summer Semester Evaluation, 2015: 75.00

Fall Semester Evaluation, 2015: 90.00

Spring Semester Evaluation, 2016: 83.00

Summer Semester Evaluation, 2016: 78.00

Fall Semester Evaluation, 2016: 93.00

Spring Semester Evaluation, 2017: 86.00

Summer Semester Evaluation, 2017: 79.00

Fall Semester Evaluation, 2017: 95.00

Current Salary: $90,000.00

NOTE: Information on the left side (ex: name of employee) is for information only. It does not need to be read.

OUTPUT

California University

Annual Employee Evaluation Report from January 1, 2015 to December 31, 2017

Name of the Employee: John Snow

Name of the Supervisor: Daenerys Targaryen

Employee ID #: A-5971-359182

Telephone Number: (745)784-5554

Address: 789 Alabama Street

Spring Semester Evaluation, 2015: 80.00

Summer Semester Evaluation, 2015: 75.00

Fall Semester Evaluation, 2015: 90.00

Spring Semester Evaluation, 2016: 83.00

Summer Semester Evaluation, 2016: 78.00

Fall Semester Evaluation, 2016: 93.00

Spring Semester Evaluation, 2017: 86.00

Summer Semester Evaluation, 2017: 79.00

Fall Semester Evaluation, 2017: 95.00

Final Weighted Evaluation, 2015: Computed Value

Final Weighted Evaluation, 2016: Computed Value

Final Weighted Evaluation, 2017: Computed Value

Total Final Weighted Evaluation: Computed Value

Average Final Weighted Evaluation: Computed Value

Current Salary: $90,000.00

Salary Raise in %: Computed Value

Salary Raise in Dollars: Computed Value

Salary in dollars with the raise: Computed Value

Warning/Appreciation Letter: Drafted by the student and stored in the Input File.

Note: This report for John Snow was prepared according to the fair practice of the University.

Any discrepancies must be reported by John Snow to her supervisor, .Daenerys Targaryen

Program

#include #include #include #include

using namespace std;

int main () { //Declaring variables string heading,heading2,employee,supervisor,id,address,number; double fall,spring,summer,fwe,salary_raise;

//Declare input file stream variable and open the input file. ifstream fin; fin.open("Input.txt"); //read the lines of the file getline(fin,heading); getline(fin,heading2); getline(fin,employee); getline(fin,supervisor); getline(fin,id); getline(fin,address); getline(fin,number); fin>>fall; fin>>spring; fin>>summer;

//Declare output file stream variable and open the output file. ofstream fout; fout.open("Output.txt");

//Writing to the output file fout << "\t \t \t" << heading<< endl; fout << "\t " << heading2 << endl << endl; fout << right << setw(45) << "Name of the Employee: " << employee << endl; fout << setw(45) << "Name of the Supervisor: " << left << setw(50) << supervisor<< endl; fout << right << setw(45) << "Employee ID: " << left << setw(50) << id<< endl; fout << right << setw(45) << "Telephone Number: " << number << endl; fout << right << setw(45) << "Address: " << address << endl; fout << setw(45) << "Fall Semester Evaluation: " << setprecision(2) << fixed << fall<< endl; fout << setw(45) << "Spring Semester Evaluation: " << setprecision(2) << fixed << spring <

//finalgrade calculation fwe=(fall*.36)+(spring*.38)+(summer*.26);

//setprecision manipulator and fixed manipulator. //Output the final weighted evaluation to output file fout << setw(45) << "Final Weighted Evaluation: "<< setprecision(2)<< fixed << fwe<< endl;

//Salary Raise Calculation if (fwe < 75) salary_raise = 0; if (fwe >= 75 && fwe <= 80) salary_raise = 1; if (fwe > 80 && fwe <= 90) salary_raise = 3; if (fwe > 90 && fwe <= 100) salary_raise= 5; if (fwe > 100) salary_raise=10;

//writing total salary raise on output file fout << setw(45) << "Salary Raise: "<< salary_raise << "%" << endl << endl;

//Warning / Appreciation Letter Calculation, Writing statement to output file if (fwe<70) { fout << "WARNING. Your Final Weighted Evaluation Report is less than 70. You need to do better." << endl; } if (fwe>=95) { fout << "CONGRATULATIONS. Your Final Weighted Evaluation Report is higher than 95. CONGRATS!!!." << endl << endl;

}

//Following statements will be displayed on the output file fout << "Note: This report for " << employee << " was prepared according to the fair practice of the University"<< endl; fout << "Any discrepancies must be reported by " << employee << " to his supervisor, "<< supervisor << "." << endl;

//close the files fout.close(); fin.close();

return 0 ; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!