1.) So I have four while loops, and I didn't close the code, reason being because I don't know where to put the brackets, so when I run the program, it loops infinitely. Please help me on where to put the brackets, when I try I get a lot of errors. Now someone did tell me I put way more while loops than need be, if that's the case what do i replace it with?
2.) How do I get an input and output for the code? I think I have to write a function but I have no idea which function to write, if you can help me with both that would be very much appreciated.
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include "Source.h"
usingnamespace std;
int main()
{
string payrate, hours, wages, name;
string inputfile, outputfile;
int empID;
cout << "Enter the name of the input file. ";
cin >> inputfile;
cout << "Enter the name of the output file. ";
cin >> outputfile;
cout << "Enter an employee number for your search. " << endl;
cin >> empID;
do
{
(empID > 0);
} while cout << " The number you entered is valid " << endl;
cin >> empID;
(empID < 0);
cout << " The number you entered is invalid, please enter a valid response. " << endl;
cout << "Employee " << empID << " worked " << hours << " hours " << " at " << payrate << " per hour and earned " << wages << endl;
cout << "Enter an employee number for your search. " << endl;
cin >> empID;
do
{
(empID > 0);
} while cout << " The number you entered is valid " << endl;
(empID < 0);
cout << " The number you entered is invalid, please enter a valid response. " << endl;
cin >> empID;
cout << "Employee " << empID << " worked " << hours << " hours " << " at " << payrate << " per hour and earned " << wages << endl;
cout << "Programmer, please enter your name here. " << endl;
cout << "Processing completed. " << endl;
system("pause");
return 0;
}
}
#include <iostream>
#include <string>
#include <fstream>
usingnamespace std;
int main()
{ string payrate, hours, wages, name;
string inputfile, outputfile;
int empID;
cout << "Enter the name of the input file. ";
cin >> inputfile;
cout << "Enter the name of the output file. ";
cin >> outputfile;
// You need to open the input and output files
cout << "Enter an employee number for your search. " << endl;
cin >> empID;
while (empID <= 0)
{ // Not valid
cout << " The number you entered is not valid " << endl;
cin >> empID;
}
// Need to initialize hours, payrate and wages
cout << "Employee " << empID << " worked " << hours << " hours " << " at " << payrate << " per hour and earned " << wages << endl;
cout << "Processing completed. " << endl;
system("pause");
return 0;
}