Monday, June 27, 2011

(Attock VU Group) Important about CS201 Assignment#4 Solution

#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

--
Group Basic Rules:
 
Immoral & Rudish talk, Earning program links, Cell number for friendship purpose, Websites/Groups Links, Adult contents, Spamming are strictly prohibited and banned in group.
 
 
 
Follow these detailed Group Rules, otherwise you will be banned at any time.
https://docs.google.com/document/d/1YJxA8x3_U7C1lRc0EXfLrJpco4A1XkB1vDxOTqOd3Jg/edit?hl=en&authkey=CNDy9tkJ
 
Group Email Address:
Attock-VU-Group@Googlegroups.Com
 
Join group by sending a blank email from University ID at:
Attock-VU-Group+Subscribe@Googlegroups.Com
 
 
Click here to Join this group at Facebook:
https://www.facebook.com/home.php?sk=group_111877855568034

No comments:

Post a Comment