PART 1: Write a program in C++

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).

  1. Note that there are 2 parts to this program. When you add a cpp file to your project to write a code, you will first need to write the program to part 1, compile and run it. Then use that same cpp file to write your new code for part 2. That is why I require you finish part 1, put your entire code within block comments ( /* …….  */)  and then  write in your new code for Part 2. This way I can what you wrote for part 1, and also run your code for part 2.

//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;
}

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

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.

Money-back guarantee

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 more

Zero-plagiarism guarantee

Each 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 more

Free-revision policy

Thanks 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 more

Privacy policy

Your 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 more

Fair-cooperation guarantee

By 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