CS201 Assignment No. 4
Page 1 of 1 • Share
CS201 Assignment No. 4
Assignment No. 04
Semester: Spring 2011
CS201: Introduction to Programming
Total Marks: 20
Due Date:29/06/2011
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
§ The assignment is submitted after due date.
§ The submitted assignment does not open or file is corrupt.
§ All types of plagiarism are strictly prohibited.
Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. If you will submit code in .doc (Word document) you will get zero marks.
Objective
The objective of this assignment is to provide hands on experience of using
§ Streams in C/C++
Guidelines:
§ Code should be properly aligned and well commented.
§ Follow c/c++ rules while writing variables names, function names etc
§ Use only dev-C++ for this assignment.
Assignment:
Problem Statement:
Printing Electricity Bill
Detailed Description:
Write a C++ program in which you have to:
1. Create a text file “Electricity_Bill”.
2. Write following data in it:
Electricity Consumer Bill
---------------------------------------------------------------------------
Reference No Tariff Load Old A/C No
123456789123456 2 1 123456789123456
---------------------------------------------------------------------------
Name and Address
XYZ Lahore Pakistan
---------------------------------------------------------------------------
Reading MF Total Unit Consumed Total Cost of electricity
55671 1 328 9999
---------------------------------------------------------------------------
Month Units Bill Current Bill 10732
Jan-11 312 5000 Arrears 0
Feb-11 312 5000 Tariff Subsidy NA
Mar-11 312 5000 Payable within Duedate 10732
---------------------------------------------------------------------------
3. Open file and read data from it and display it on the screen.
Sample Output
[You must be registered and logged in to see this image.]
Semester: Spring 2011
CS201: Introduction to Programming
Total Marks: 20
Due Date:29/06/2011
Instructions
Please read the following instructions carefully before submitting assignment:
It should be clear that your assignment will not get any credit if:
§ The assignment is submitted after due date.
§ The submitted assignment does not open or file is corrupt.
§ All types of plagiarism are strictly prohibited.
Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. If you will submit code in .doc (Word document) you will get zero marks.
Objective
The objective of this assignment is to provide hands on experience of using
§ Streams in C/C++
Guidelines:
§ Code should be properly aligned and well commented.
§ Follow c/c++ rules while writing variables names, function names etc
§ Use only dev-C++ for this assignment.
Assignment:
Problem Statement:
Printing Electricity Bill
Detailed Description:
Write a C++ program in which you have to:
1. Create a text file “Electricity_Bill”.
2. Write following data in it:
Electricity Consumer Bill
---------------------------------------------------------------------------
Reference No Tariff Load Old A/C No
123456789123456 2 1 123456789123456
---------------------------------------------------------------------------
Name and Address
XYZ Lahore Pakistan
---------------------------------------------------------------------------
Reading MF Total Unit Consumed Total Cost of electricity
55671 1 328 9999
---------------------------------------------------------------------------
Month Units Bill Current Bill 10732
Jan-11 312 5000 Arrears 0
Feb-11 312 5000 Tariff Subsidy NA
Mar-11 312 5000 Payable within Duedate 10732
---------------------------------------------------------------------------
3. Open file and read data from it and display it on the screen.
Sample Output
[You must be registered and logged in to see this image.]
kamran- Monstars
-
Posts : 301
Join date : 2011-02-11
Age : 36
Re: CS201 Assignment No. 4
Solution:
- Code:
#include<iostream.h>
#include<fstream.h>
main()
{
ifstream inFile;
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");
}
[You must be registered and logged in to see this image.]
Bano Zulaikha- Monstars
-
Posts : 20
Join date : 2011-06-27
Age : 43
Character sheet
Experience:
(5/5)
Bano Zulaikha- Monstars
-
Posts : 20
Join date : 2011-06-27
Age : 43
Character sheet
Experience:
(5/5)
Similar topics
» CS201 Assignment No. 3
» CS201 Assignment No.2 Solution
» CS201 GDB solution
» CS507 Assignment No. 4
» MGT504 Assignment
» CS201 Assignment No.2 Solution
» CS201 GDB solution
» CS507 Assignment No. 4
» MGT504 Assignment
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Yesterday at 10:48 am by ali001
» Storybook Magic App
Tue Apr 30, 2024 7:06 pm by ali001
» Flower Book Match3 Puzzle Game
Tue Apr 30, 2024 12:17 pm by ali001
» Avian Influenza Symptom in Chickens "Bird Flu H5N1 Virus" Vet learning materials, Poultry Farming
Sat Apr 27, 2024 9:57 am by Ibad Khan Buledi
» house disrepair claims
Mon Apr 22, 2024 11:23 am by Joshuaadam
» Aloha Planner - Note-Taker
Thu Apr 11, 2024 4:52 pm by ali001
» Streaming Guide Film TV Series
Tue Apr 09, 2024 9:39 pm by ali001
» Apricot Tree Problems & Solutions ????|خوبانی کے پھل کو کیڑا لگنےسے بچانے کا طریقہ ????
Sun Apr 07, 2024 6:28 am by Zamaan Khan
» خوبانی کے پودے کی کاشت گرم علاقوں میں کرنی چاہیے یا نہی
Sun Apr 07, 2024 6:24 am by Zamaan Khan