Need urgent solution for this problem

i have develop a very small program in C++
but its not working correctly
can anyone help me on urgent basais
my code is the following
i think so error is here

if the salary is less than 10000 SR there should be
cout<<

"Sorry, your salary is not enough to have a loan\n" << endl << endl;


if not, multiplay the salary by 0.4 to get a_month (a_month=salary*0.4)

then, multiplay xa_month by 12 to get a_year.(a_year=12 *a_month)

then, multipay a_year by 7 to get tatal_pay. (tatal_pay=7*a_year)

then, subtract total_pay by 50000 to get total_give. (total_give=tatal_pay-50000)


_____________________________________________________


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#include <iostream>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstddef>
#include <iomanip>

using namespace std;

class Money
{
public:
	friend bool operator >= (const Money& amount1, const Money& amount2);
    friend ostream& operator << (ostream& outs,  Money& amount);
	friend istream& operator >> (istream& ins,  Money& amount);
	Money mon (Money& amount1);
	Money year (Money& amount1);
	Money pay (Money& amount1);
    Money give (Money& amount1);
    Money ();
	Money(int size1);
	Money(const char a[]);
	Money(const Money& money_object);
	~Money();
	int lenght() const;
	void input(istream& ins);
	void output();


private:
    char *name;
	int size;
	double value;
	double a_month;
	double a_year;
	double total_pay;
	double total_give;
	double m;
};

Money::Money(const char a[]): size(strlen(a))
{
	name= new char[size+1];
	strcpy(name, a);
}
Money::Money(const Money& money_object):size(money_object.lenght())
{
    name= new char[size+1];
	strcpy(name, money_object.name);
}
bool operator >= (const Money& amount1, const Money& amount2)
{
	return (amount1.value >= amount2.value);
}

Money Money::mon ( Money& amount1)
{
	Money temp;
		temp.a_month= amount1.value * 0.4;
		return temp;
	
}

Money::Money(): size(500)
{
	name= new char[size+1];
	name[0]='\0';
}
int Money::lenght() const
{
	return strlen(name);
}

Money::Money(int size1): size(size1)
{
	name= new char[size+1];
	name[0]='\0';
}

Money::~Money()
{
	delete[] name;
}
void Money::input(istream& ins)
{
	ins.getline(name, size+1);
}

Money Money::year (Money& amount1)
{
Money temp;	

	temp.a_year= amount1.a_month * 12.0;
	
	return temp;
}

Money Money::pay (Money& amount1)
{
	Money temp;
	temp.total_pay= amount1.a_year * 7.0;
	return temp;
}

Money Money::give (Money& amount1)
{
	Money temp;
	total_give= amount1.total_pay - 50000.0;
	return temp;
	
}

void Money::output()
{
	cout<< "You will pay a month " << a_month << " SR"<< endl << endl;
	cout<< "So the total amount that you will pay a year is " << a_year << " SR" <<endl << endl;
	cout<< "You will continue to pay for 7 years" << endl << endl;
	cout<< "The total amount of money you pay all the 7 years is " << total_pay << " SR" << endl << endl;
	cout<< "The amount of interest money the Bank take is 50,000 SR" << endl << endl;
	cout<< "So the Total amount of money the Bank will give you is " << total_give << " SR" << endl << endl;
}
ostream& operator << (ostream& outs,  Money& amount)
{
    outs<< amount.name;
    return outs;
}


istream& operator >> (istream& ins,  Money& amount)
{
	ins >> amount.value;
    return ins;
}


int main()
{
	system ("color 5");
	Money com, salary(500), our("Rawan"), min, h;
	cout<< "Hello\n" << "I am " ;
	cout<< our;
	cout<< endl;
	cout << "This a program to help you if you want to take a loan from a Bank.\n" 
	<< "You can know the following:\n" << "1- If your salary allows you to take a loan.\n" 
	<< "2- The toltal amout of money the Bank will give you.\n"
	<< "3- The total amount of money you will pay a month and a year.\n"
	<< "4- The Total money you will pay all the years\n" 
	<< "5- The interect the Bank will take from you\n" << endl;
	cout<< "What is your name?\n";
	salary.input(cin);
	system ("cls");
	system ("color 3");
	cout<< "OK " ;
	cout<< salary;
	cout<< endl;
	cout<< "What is your salary?\n" ;
	salary.input(cin);
	system ("cls");
	system ("color 2");
	cout<< "Your Salary is : " ;
	cout<< salary;
	cout<< endl;
	
	if(salary >= 10000)
	{
		salary=salary.mon(salary);
		salary=salary.year(salary);
		salary=salary.pay(salary);
		salary=salary.give(salary);

		system ("cls");
		system ("color 3");
		salary.output();
	}
	else
	{
		cout<< "Sorry, your salary is not enough to have a loan\n" << endl << endl;
	}
	
	cout<< "Thank you "; 
	cout<< salary;
	char c;
	cin>>c;
	return 0;
}

I think your problem is in your copy constructor
1
2
3
4
5
Money::Money(const Money& money_object):size(money_object.lenght())
{
    name= new char[size+1];
	strcpy(name, money_object.name);
}

This is called when you assign stuff and it doesn't really assign much. You could either add many lines (such as value = money_object.value; and so on) or simply remove it, since it doesn't seem to do anything the default constructor wouldn't.
Default copy constructors and assignment operators do not make deep copies. Speaking of the assignment operator, where is it?
dear i am totly new in c++
just plz tell me what i can do this program will work fine and give me the correct output....which i mention in the above before code...
please help me dear...........
Stop spamming other threads. You'll only encourage people not to help you.
my dear i need help so thats why i am saying plz anyone can help me............
is their any one can help me to solve this problem...
i just want to execute this program with out errors...
Topic archived. No new replies allowed.