I am stressed, beyond confused, angry, and really anxious about these directions, and it’s making me feel like I want to break something. the instructions point out that both parts need to be submitted on a single .cpp file, but it’s giving me a problem after problem after problem. I’ll post the instructions below, then post what the submission instructions are, then what I currently have written below that. this is my S.O.S. Call, please help me, I’m at my witts end!
PART 1: Write a program in C++ that permits users to enter the following information about your company’s five employees and writes the following information to the file (data.txt).
ID no. Name Sex (M/F) Hourly Wages Years with company
All information must be displayed in a well formatted manner, so you can put in relevant manipulators for this purpose.
Run your program, put in employee information, and verify if you have a txt file as required.
PART 2:
At this point you must have a .txt file with information of 5 employees.
Go back to your C++ program (from part 1), put the entire existing program from part 1 within block comments.
Now write a new program for part 2 (in that same C++ file) as per instructions given below.
Write a C++ program that reads this file data.txt, one line at a time, asks for the number of hours worked by each employee and calculates their total pay for the month. So for each of the employee records that stream in, your program must ask user:
Enter hours worked by (name of employee):
When user puts in the answer, program must calculate the total salary and display on the computer screen as ‘ The salary of (name) is $ (salary).
//include necessary header files
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
#include <iomanip>
using namespace std;
int main() //main method
{
//declare variables
string filename = “data.txt”;
const int num = 5;
string sex[num];
string name[num];
int ID[num], years[num];
double wages[num];
ofstream gm; // ofstream objects
gm.open(filename.c_str()); //open file
if (gm.fail()) //check if file is opened successfully
{
cout << “the file was not successfully opened” << endl;// displays message
exit(1);
}
gm << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2);//for loop
for (int i = 0; i < num; i++)
{
cout << “Enter Employee ID: “; //displays message to enter ID
cin >> ID[i]; //reads imput from user
cout << “\n Enter Employee Name: “;//displays message to enter name
cin >> name[i];//reads imput from user
cout << “\n Enter Sex (M/F): “;//displays message to enter employee’s gender
cin >> sex[i];//reads imput from user
cout << “\n Enter Hourly Wages: “;//displays message to enter hourly salary
cin >> wages[i];//reads imput from user
cout << “\n Enter number of years with company: “;//displays message to enter number of years with company
cin >> years[i];//reads imput from user
}
//declare required variables
int tempID, tempyears;
string tempsex;
string tempname;
double tempwages;
return 0;
}
//part2
int main()
//declare variables
string filename2 = (“data.txt”);
const int num = 5;
string name[num];
double hours[num];
double wages[num];
double weeklyhrs;
double weeklypay;
double monthlyhrs;
double monthlypay;
int weekBeingPaid();
int monthBeingPaid();
ofstream gm; //ofstream object
gm.open(filename2.c_str());
if (gm.fail()) //check if file is open successfully
{
cout << “the file couldn’t be opened successfully” << endl;
exit(1);
}
gm << setiosflags(ios::fixed) << setiosflags(ios::showpoint) << setprecision(2); //for loops
for (int i = 0; i < num; i++)
{
cout << “Enter Employee’s Name: “;//displays message to enter employee name
cin >> name[i];//reads imput from user
cout << “\n Enter Employee’s Hourly Wage: “;//displays message on entering hourly wage
cin >> wages[i]; //reads imput from user
cout << “\n Enter Hours Worked by Employee: “;//displays message on entering hours worked by employee
cin >> hours[i];//reads imput from user
}
//calculate weekly pay
for (int i = 0; i < num; i++)
{
weeklyhrs = hours[i] * 5; //calculate weekly hours worked
weeklypay = weeklyhrs * wages[i]; //calculate weekly pay
//calculate monthly pay
monthlyhrs = weeklyhrs * 4; //calculates hours worked in a month
monthlypay = weeklyhrs * 4; //calculates monthly payment
}
cout << name << “\n Works: ” << weeklyhrs << “and earns: ” << weeklypay << “per week”;
weeklyhrs++;
weeklypay++;
cout << “\n The Salary of” << name << “Is: $ ” << monthlypay << “Per Month”;
monthlypay++;
return 0;
}
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more
Recent Comments