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:
- Classes and Objects
- Overloading constructors
- Use of new operator
- Friend Functions
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: Calculating customer’s bill using classes You are required to write a program for calculating the bill of a customer according to the amount spent on shopping. A customer will be an object of a class. Each object has a name, customer ID and amount spent on shopping, as its data members. You will calculate the total bill by adding tax in the spending and subtracting discount offered according to spending. Detailed Description:
- You are required to create a class named Customer.
- It will have name, customer-ID and spending as its private data members.
- You have to make two constructors for this class, i.e. default constructor and parameterized constructor.
- Default constructor will initialize the name with "No name", customer-id with "0" and spending with "0";
- Parameterized constructor will take three arguments i.e. name, customer-id and spending.
- Create getter and setter functions for each data member of the class.
- A friend function will calculate the total bill for each object of class Customer, passed to it as argument.
- If total spending is less than 5000, then tax added on total spending is 5% and discount is 1%. If spending is more than 5000 and less than 10,000 then 10% tax and discount is 2% and if spending ismore than 10,000 then 15% tax and 3% discount is applicable.
- Remember that all this calculation will be done inside friend function.
- In the main() function, create three customer type objects by using new operator. Initialize first object with default constructor, second with parameterized and take input from user for third object (use setter functions to set third object’s values taken from the user).
- Calculate total bill for all three objects by passing them to friend function and then display the result of calculation as shown in example output.
|