#include<iostream.h>
#include<fstream.h>
main()
{
ifstream inFile;
ofstream outFile;
char outputFileName[]="Electricity_Bill.txt";
char outputText[]="\t\t\tElectricity Consumer Bill\n"
"---------------------------------------------------------------------------\n"
"Reference No Tariff Load Old A/C No\n"
"123456789123456 2 1 123456789123456\n"
"\n---------------------------------------------------------------------------\n"
"Name and Address \n"
"XYZ Lahore Pakistan \n"
"\n---------------------------------------------------------------------------\n"
"Reading MF Total Unit Consumed Total Cost of electricity\n"
"55671 1 328 9999\n"
"\n---------------------------------------------------------------------------\n"
"Month Units Bill Current Bill 10732\n"
"Jan-11 312 5000 Arrears 0\n"
"Feb-11 312 5000 Tariff Subsidy NA\n"
"Mar-11 312 5000 Payable within Duedate 10732 \n"
"\n---------------------------------------------------------------------------\n";
outFile.open(outputFileName, ios::out);
if(!outFile)
{
cout << "Can't open file named " << outputFileName << endl;
exit(1);
}
outFile << outputText;
outFile.close();
char inputFileName[]="Electricity_Bill.txt";
const int MAX_CHAR_TO_READ = 100;
char completeLineText[MAX_CHAR_TO_READ];
inFile.open(inputFileName);
if(!inFile)
{
cout <<"Can't open input file named " << inputFileName << endl;
exit(1);
}
while(!inFile.eof())
{
inFile.getline(completeLineText,MAX_CHAR_TO_READ);
cout << completeLineText << endl;
}
inFile.close();
system("pause");
}
Assalam o alaikum dear members
The solution of CS201 assignment#4 shared by me was wrong or you can say incomplete
I created a text file and then wrote a program which opens the the text file, read the data from the text file and then display in on the screen
whereas according to the requirements of the assignment
we have to write a C++ program which will automatically create a text file,
write the date in the text,
open the text file, read the date from the file and display in on the screen
i corrected the solution file and attached it
--
Join us at facebook: https://www.facebook.com/VU.Study.Corner
Group Link: http://groups.google.com/group/VU-Study-Corner?hl=en
Group Rules: http://groups.google.com/group/VU-Study-Corner/web/group-rules
Unsubscribe: VU-Study-Corner+unsubscribe@googlegroups.com
Adult contents, Spamming, Immoral & Rudish talk, Cell number, Websites & Groups links specially in paper days are strictly prohibited and banned in group.
No comments:
Post a Comment