i'm learning c++,and i'm attempting to do the following problem:
plxx some1 solv it......
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. 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 need to overload stream insertion << and stream extraction >> operators for the Customer class.
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.
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
Your detailed description forms a design, so try copying in into a blank .cpp file as comments. Then go through & write code that does what is written in the comments.
The order of the code won't exactly follow the comments, but at least it will give you a start.
i have codes bt with error if somebody can correct this.....??
Are you just kidding? You've lots of "easy to fix" syntax errors in your code. This kind of errors are simple to solve, even for a newbie.
We can help you with more difficult/semantic problems...
Like engelsbr said you have forgotten the output operator << at many places. The other "error" is outputstar. You have declared star as an own function which takes an output stream as parameter. So you have to call star(output) instead of outputstar.
After cleaning up this errors your program works well on my machine.
If you have lots of compile errors you don't understand, then post your compiler output, we can explain / point out stuff about these errors.
If you do this, the line numbers from the compiler won't match the line numbers in your code (when you post it in tags that is), so can you let us know how they match up.
To use code tags, use the <> button on the right under format, and it should look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include<iostream>
#include<conio.h>
#include<stdlib.h>
usingnamespace std;
class Customer
{
private:
string Name;
int CustomerId;
int Spending;
int tax;
int discount;
int totalbill;