-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathremove.cpp
More file actions
65 lines (62 loc) · 1.38 KB
/
remove.cpp
File metadata and controls
65 lines (62 loc) · 1.38 KB
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
/**
* @Date: 2019-04-27T22:14:45+08:00
* @Last modified time: 2019-04-27T23:29:04+08:00
*/
#include "test.h"
void remove(data* &spendings, int size)
{
data *temp = new data[size];
int date;
int pos=0;
string type;
string category;
double amount;
string method;
cout<<"Insert date (dd): ";
cin>>date; //Insert the date of the data.
cout<<"Insert type (Income or Expense): ";
cin>>type; //Insert type of data.
if(type=="Expense") //Insert category.
{
cout<<"Insert category ";
cout<<"(Food, Transport, Shopping, Others): ";
cin>>category;
}
if(type=="Income")
{
category="-";
}
cout<<"Insert payment method(Cash/DebitCard/CreditCard/Others): "; //Get the method of data.
cin>>method;
cout<<"Insert value: "; //Get the amount of value of the data.
cin>>amount;
for(int i=0;i<size;i++)
{
if(spendings[i].date==date)
{
if(spendings[i].type==type)
{
if(spendings[i].category==category)
{
if(spendings[i].amount==amount)
{
if(spendings[i].method==method)
{
pos=i;
}
}
}
}
}
}
int j=0;
for (int a=0;a<size-1;++a){ //Remove data.
if (a==pos){
j+=1;
}
temp[a]=spendings[j];
j+=1;
}
spendings= NULL;
spendings=temp;
}