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 : 37
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
» MGT613 Assignment No. 1
» ENG 301 Assignment No. 1 Solution
» CS201 Assignment No.2 Solution
» CS201 GDB solution
» MGT613 Assignment No. 1
» ENG 301 Assignment No. 1 Solution
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
Yesterday at 12:21 pm by ali001
» Hemangiom'App
Tue Nov 05, 2024 11:25 am by ali001
» MindfulMe - Mental Health App
Mon Nov 04, 2024 10:50 am by ali001
» Learn Candlestick Patterns
Tue Oct 15, 2024 5:51 am by ali001
» Woh Pagal Si Episode 52 to 62 - Top Pakistani Drama
Sat Sep 21, 2024 6:26 pm by Mir Emmad Ali Khan Domki
» Nearu - share your socials
Sat Sep 21, 2024 1:12 pm by ali001
» Nightclub Tycoon: Idle Empire
Thu Sep 19, 2024 9:16 pm by ali001
» Carnivore - Meat Diet Recipes
Wed Sep 18, 2024 2:37 pm by ali001
» Eid Milad un Nabi Mubarak 2024 (Rabiʻ I 14, 1446 AH)
Tue Sep 17, 2024 3:44 pm by Mir Emmad Ali Khan Domki