473,434 Members | 1,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

How to use delete in string in c++ With using class (delete information)

2
Hi, friends:

This is my programme (work on Microsoft visual c++) and I have two question .

First, I want to say that there is no error but I need a little help.

This is a small programme about Bank :


it's work but my question is (about 6-closing account) on function closing account....
.....How could I delete the information in this function to close account by using string (I know how to delete in pointer,but
here I don't use pointer ,I want to use string) should I make it zero's (but I don't think so )
...I really need a help........

Please Help




and I have another question but not importante like the first one , that if I want to use two class in the
programme not one class , I'll make it class Bank (which have making new account & closing account & Zakat account) and the
other class is class account (which have the deposit & the withdrawal & the display of information for just one account)


Expand|Select|Wrap|Line Numbers
  1.  #include <iostream> 
  2. #include <string> //Must include this to use class string 
  3.  
  4. using namespace std; 
  5. class account 
  6. private: 
  7. //int size; 
  8. //int customer; 
  9. string firstname,lastname,name; 
  10. double accountbalance,amount1,amount2; 
  11. int index; 
  12.  
  13. double zakat1,zakat; 
  14. int num,i,month; 
  15. /*static*/ int counter; 
  16.  
  17.  
  18. public: 
  19.  
  20. account(){index=1;counter=0;cout<<"account constructor\n";} 
  21. void newaccount(); 
  22. void closeaccount(); 
  23. void calzakat(); 
  24. ~account(){cout<<"account destrurctor\n";} 
  25. void depositing(); 
  26. void withdrawal(); 
  27. void displayaccount(); 
  28. }; 
  29. //static int bank::counter=0; 
  30. void account::newaccount() 
  31. cout<<"enter the customer firstname,lastname,account balance\n"; 
  32. //customer=index; 
  33. cin>>firstname; 
  34. cin>>lastname; 
  35. name=firstname+lastname; 
  36. cin>>accountbalance; 
  37. index++; 
  38. counter++; 
  39. void account::closeaccount() 
  40. //name=' '; 
  41. accountbalance=00.00; 
  42. counter--; 
  43. /* 
  44. for(int y=0;y<index;y++) 
  45. if((y==num)||(y>num)) 
  46. customer[y]=customer[y+1]; 
  47. name[y]=name[y+1]; 
  48. accountbalance[y]=accountbalance[y+1]; 
  49. customer[size-1]; 
  50. name[size-1]; 
  51. accountbalance[size-1];*/ 
  52. void account::calzakat() 
  53. cout<<"enter how many month is ago from last deposite money in the account th to calculate zakat\n"; 
  54. cin>>month; 
  55. if((accountbalance>4000)&&(month>12)) 
  56. zakat1=((accountbalance*2.5)/100); 
  57. accountbalance=accountbalance-zakat1; 
  58. cout<<" the name of the customer "<<name; 
  59. cout<<" the account balance "<<accountbalance<<"\n"<<"the zakat is\n"<<zakat1<<"\n"; 
  60. else 
  61. zakat1=00.00; 
  62. cout<<" the name of the customer "<<name; 
  63. cout<<" the account balance "<<accountbalance<<"\n"<<zakat1<<"\n"; 
  64. zakat=zakat+zakat1; 
  65.  
  66.  
  67.  
  68.  
  69.  
  70. void account::depositing() 
  71. cout<<"enter the amount you want to depositing\n"; 
  72. cin>>amount1; 
  73. accountbalance=accountbalance+amount1; 
  74. cout<<"the account balance after the depositing\n"<<accountbalance; 
  75. void account::withdrawal() 
  76.  
  77. cout<<"enter the amount you want to withdrawal\n"; 
  78. cin>>amount2; 
  79. if (amount2<=accountbalance) 
  80. accountbalance=accountbalance-amount2; 
  81. cout<<"the account balance after withdrawal from it\n"; 
  82. cout<<accountbalance; 
  83. else 
  84. cout<<"sorry..the account is less than the amount you want to withdrawal\n"; 
  85.  
  86.  
  87. void account::displayaccount() 
  88. cout<<"the name of customer is\n"<<name<<"\nthe account balance is\n"<<accountbalance<<"\n"; 
  89.  
  90.  
  91. int main() 
  92. int choice,accountnum,x; 
  93. account ob[3]; 
  94.  
  95. do 
  96. cout<<"enter your choice\n"; 
  97. cout<<"1-Opening a new account for a customer\n"; 
  98. cout<<"2-deposit to the account\n"; 
  99. cout<<"3-withdrawal from the account\n"; 
  100. cout<<"4-Zakat calculate and debits the account zakat\n"; 
  101. cout<<"5-display the information of account\n"; 
  102. cout<<"6-closing an account\n"; 
  103. cout<<"7-display all account information\n"; 
  104. cout<<"8-exit\n"; 
  105. cin>>choice; 
  106. switch(choice) 
  107. case 1: 
  108.  
  109. cout<<"enter the account number from 0 to 14\n"; 
  110. cin>>accountnum; 
  111. x=accountnum; 
  112. cout<<"the account has the number "<<x; 
  113. ob[accountnum].newaccount(); 
  114. break; 
  115. case 2: 
  116. cout<<"enter the account number from 0 to 14 to depositing it\n"; 
  117. cin>>accountnum; 
  118. x=accountnum; 
  119. cout<<"the account has the number "<<x; 
  120. ob[accountnum].depositing(); 
  121. break; 
  122. case 3: 
  123. cout<<"enter the account number from 0 to 14 to withdrawal from it\n"; 
  124. cin>>accountnum; 
  125. x=accountnum; 
  126. cout<<"the account has the number "<<x; 
  127. ob[accountnum].withdrawal(); 
  128. break; 
  129. case 4: 
  130. cout<<"enter the account number from 0 to 14 to calculate zakat to it\n"; 
  131. cin>>accountnum; 
  132. x=accountnum; 
  133. cout<<"the account has the number "<<x; 
  134. ob[accountnum].calzakat(); 
  135. break; 
  136. case 5: 
  137. cout<<"enter the account number from 0 to 14 to display it\n"; 
  138. cin>>accountnum; 
  139. x=accountnum; 
  140. cout<<" the account that has the number "<<x; 
  141. ob[accountnum].displayaccount(); 
  142. break; 
  143. case 6: 
  144. cout<<"enter the account number from 0 to 14 to close it\n"; 
  145. cin>>accountnum; 
  146. x=accountnum; 
  147. cout<<"the account has the number "<<x; 
  148. ob[accountnum].closeaccount(); 
  149. break; 
  150. case 7: 
  151. int i; 
  152. for(i=0;i<3;i++) 
  153. cout<<"the zakat of the account that has the number "<<i; 
  154. ob[i].displayaccount(); 
  155. break; 
  156. case 8: 
  157. cout<<"the exit\n"; 
  158. break; 
  159. default: 
  160. cout<<"invalid choice\n"; 
  161. break; 
  162. }//end switch 
  163. }//end while 
  164. while(choice!=8); 
  165. return 0; 
  166.  
Thank you all very much..........I hope if any one can help me ..
..........I need it tomorrow .... :o
Nov 20 '05 #1
2 10201
memosa
2
thanks i solved it with flag
Nov 22 '05 #2
memosa is there any chance to post your solution...
I have th same problem and i have to give my work yesterday...

The code works in the same way in c++??
Feb 10 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Nimmi Srivastav | last post by:
There's a rather nondescript book called "Using Borland C++" by Lee and Mark Atkinson (Que Corporation) which presents an excellent discussion of overloaded new and delete operators. In fact there...
4
by: Eric A. Johnson | last post by:
Hi, I am working on a way to create a "window" within a dos console. I'm using Microsoft Visual C++. My main problem is that I am using new to create a new CHAR_INFO array within the...
0
by: Kevin | last post by:
I am successfully creating and deleting appointments and sending invitations in a C# / ASP.NET / Exchange2000 environment. It works great! But the problem is that no notifications are sent out...
0
by: laurent | last post by:
Environment: VS NET 2003 Fr Framework: 1.1 OS: WinXP SP2 Fr Hello I have a problem to add with pop-up and to delete in a datagrid(ButtonColumn delete) on WebForms. code button HTML which...
3
by: silver360 | last post by:
Hello, I'm trying to create a basic Heap manager and i have some question about new/delete overloading. The following code give me this output : >> $./heap >> registered : 0x804d098 >>...
6
by: polocar | last post by:
Hi, I'm writing a program in Visual C# 2005 Professional Edition. This program connects to a SQL Server 2005 database called "Generations" (in which there is only one table, called...
2
by: rohits123 | last post by:
To optimize the memory usage , I am using a huge block of memory for my system and then dividing the initial chunk in to 4 pools. I have overloaded new and delete such that memory from a...
7
by: ITAutobot25 | last post by:
My delete button is not working in my GUI and my due date is today before midnight. Can anyone show me how to correct this error? My assignment statement is below as well as 5 classes. InventoryGUI...
13
by: ramprakashjava | last post by:
hi, i hav "java.lang.NullPointerException" error while Deleting table records using checkbox in jsp here i enclosed files help quickly plzzz.. ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.