Question: Make this code work, C + + . / / ( 1 ) write the preprocessing directives # include / / cin, cout, endl #
Make this code work, C write the preprocessing directives
# include cin, cout, endl
# include string variables
# include file processing
# include clear screen
using namespace std;
open the scope of the main method
int main
declare and initialize the variables
static char chrName; employee name
double myExpenses; individual expense
char myLabels; expense label
int index ; loop control variable
int number ; number of expense items
ofstream fout; file stream output
file variable initialization
fout.opendatatxt;
clear the screen for Windows users
systemCLS;
request the employee name
cout "enter the employee name: endl;
cin.getlinechrName;
request the number of expense items
cout "enter the number of expense items: endl;
cin number;
cin.ignore; skip Enter entry from keyboard;
open the looping structure
while index number
index;
request the user for an expense item
cout "enter the type of expense: endl;
cin.getlinemyLabels;
cout "enter the amount of expense: endl;
cin myExpenses;
write the data to a text file
fout chrName : myLabels
: myExpenses endl;
cin.ignore; skip Enter entry from keyboard;
close the scope of the while loop
close, ie dismiss, the file object
fout.close;
close the scope of the main method
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
