Question: ----it is not working on x code- #1 says 2 unused variables---- C++ ----------- T hese 3 questions were answered incorrectly in the expert q

----it is not working on x code- #1 says 2 unused variables---- C++ ----------- These 3 questions were answered incorrectly in the expert q qnd a- they had errors . please help if you are another expert out there. this should all be in c++

----it is not working on x code- #1 says 2 unused variables----

THIS IS THE CODE THEY GAVE ME BELOW

this code is incorrect

John Smith 10 15 Sarah Johnson 40 12 Mary Taylor 27 13 Jim Stewart 25 8

______________

#include

#include

#include

using namespace std;

//Function declaration

void readData(ifstream& dataIn,ofstream& dataOut);

int main() {

string fname,lname;

double workingHrs,hourlyRate;

//defines an input stream for the data file

ifstream dataIn;

//Defines an output stream for the data file

ofstream dataOut;

//Setting the precision

dataOut

//Opening the input file

dataIn.open("employees.txt");

//checking whether the file name is valid or not

if(dataIn.fail())

{

cout

return 1;

}

else

{

//creating and Opening the output file

dataOut.open("results.txt");

readData(dataIn,dataOut);

//Closing the intput file

dataIn.close();

//Closing the output file.

dataOut.close();

}

return 0;

}

//This function will read and process the data and write to outfile

void readData(ifstream& dataIn,ofstream& dataOut)

{

string fname,lname;

double workingHrs,hourlyRate;

while(dataIn>>fname>>lname>>workingHrs>>hourlyRate)

{

dataOut

}

}

QUESTION 2

C++ ----------- These 3 questions were answered incorrectly in the expert qTHIS IS THE CODE THEY GAVE ME

this code is incorrect

#include #include #include

using namespace std;

int getData(int *arr) { cout > filename; ifstream in(filename.c_str()); int size = 0; if(in.is_open()) { int score; string temp; while(in >> temp >> temp >> score) { arr[size++] = score; } } else { cout

double avg(int *arr, int size) { double total = 0; for(int i = 0; i

int max(int *arr, int size) { int temp = arr[0]; for(int i = 0; i temp) { temp = arr[i]; } } return temp; }

int main() { int arr[1000]; int size = getData(arr); cout

QUESTION 3

qnd a- they had errors . please help if you are another

THIS IS THE CODE THEY GAVE ME

incorrect code below

#include #include #include #include #include

void countchar(char *filename) { ifstream fin(filename); char ch; std::string line; int i,j,alpha=0,others=0,digi=0,lines=0; cout64&&i96&&i47&&i

} fin.clear(); fin.seekg (0, ios::beg); cout

cout

cout

}

int main() { char *filename="nameofyourfile.txt"; char a; countchar(filename); return 0; getch(); }

Question 1: Consider a text file named "employees.txt". The file contains data organized according to the following format: John Sarah Mary Jim Smith Johnson Taylor Stewart 10 40 27 25 15 12 13 For instance, "John" is the first name, "Smith" is the last name, "20% is the number of hours per w eek, and yis the hourly rate. Write a program that computes the weekly salary of each employee. The program prints the first name, last name, and weekly salary of each employee in a file named "results.txt". You must use a function to read/process the data from the input file and this function must have parameters

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!