-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdatedata.c
35 lines (32 loc) · 919 Bytes
/
updatedata.c
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
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "template.h"
void update(TransNode* mainhead, SellersList* sellerhead) {
printf("Enter the transaction ID to update\n");
int id;
scanf("%d",&id);
TransNode* temp=mainhead;
SellersList* sptr=sellerhead;
int flag=0;
while(temp!=NULL&&flag==0) {
if(temp->entry.transID==id) flag=1;
else temp=temp->next;
}
if(flag==1) {
printf("Enter the new amount of energy\n");
float amt;
scanf("%f",&amt);
temp->entry.amtOfEnergy=amt;
flag=0;
while(sptr!=NULL && !flag) {
if(sptr->attributes.sellerID == id) {
flag=1;
if(temp->entry.amtOfEnergy>=300) temp->entry.pricePerKWh=sptr->attributes.a300;
else temp->entry.pricePerKWh=sptr->attributes.b300;
}
else sptr=sptr->next;
}
}
else printf("No such transaction exists with the given Transaction ID\n");
}