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.
§
Assignment is copied(partial or full) from any source (websites,
forums, students, etc)
Note: You have to upload only .cpp file. Assignment in any other
format (extension) will not be accepted and will be awarded with zero marks. For
example, if you submit code in .doc (Word document) or .txt files, no reward
will be given in any case.
Objective:
The
objective of this assignment is to provide hands on experience of:
§ Using manipulators in C/C++
§ Overloading stream insertion and extraction
operators
Guidelines:
§ Code should be properly indented and well
commented.
§
Follow C/C++
rules while writing variable names, function names etc
§
Use only
dev-C++ for this assignment
Problem Statement: Customer Bill Information
Write a program that
takes customer’s information from user i.e. name, ID and spending and displays the same customer
information plus total bill on the screen.
You will use the same Customer class
implemented in Assignment#3. You
need to overload stream insertion << and stream extraction >> operators for the Customer class.
Detailed Description:
- Use the same Customer class you implemented in Assignment#3.
- This time you don’t need the friend function for calculation of total bill according to spending.
- You can modify the class (add or delete some functions) as per program requirement.
- You will overload extraction operator >> for getting input for an object of Customer class.
- You will also overload insertion operator << for displaying the customer information on screen.
- On calling extraction operator in main() e.g. cin>>obj where obj is an object of Customer class, information about customer name, ID and spending should be taken from the user.
- Take a look at the sample output for better understanding.
- On calling insertion operator in main() e.g. cout<<obj, the output in the following format should be displayed.
- You must use the formatting manipulators setw() and setfill() for formatting the text as shown in the output.
- All the formatting of text should be implemented inside overloaded function for extraction operator <<
- The main() function of your solution should contain only these instructions
Customer
obj;
cin >> obj;
cout << obj;
system(“pause”);
0 comments:
Post a Comment