Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
28 views17 pages

Case C Program

Uploaded by

liyava6499
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views17 pages

Case C Program

Uploaded by

liyava6499
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

MOBILE RECHARGE SYSTEM

A Case Study Report Submitted for Problem Solving


and
Programming with C
BY

1.BU22CSEN0102234(Vansh Agrawal)
2.BU22CSEN0102235(Yak)
3.BU22CSEN0102240(Rahul)
4.BU22CSEN0102259(Afsana)
5.BU22CSEN0102260(Achyutha)
6.BU22CSEN0102244(Santosh)
7.BU22CSEN0102241(Keerthi)
8.BU22CSEN0102257(Mohit)
9.BU22CSEN0102261(Harish)
10.BU22CSEN0102321(Sai)
11.BU22CSEN0102322(Abdul)
12.BU22CSEN0102211(Taruna)

INTRODUCTION
This case study is for Online Mobile Recharge of mobile. This is useful for
online recharging of mobile. This System provides recharge of many mobile
companies as well as all kind of recharge are possible. This System will provide
facility for customer to recharge mobile at anytime from anywhere. This System
keeps the history of the past recharges.
BACKGROUND STUDY
In the current system the user who want to recharge their mobile have to go to
any shop where recharge is available. They have to go the shop and ask for the
specific recharge. The shopkeeper keeps the record of the number in any book.
With today's busy schedule, people have no time to recharge. And sometimes it
will become difficult if the balance is completed when we are in faraway places.
Mobile recharge systems we can use anywhere this requires little knowledge;
there is no need to depend on others for recharge.

IMPLEMENTATION:
#include<stdio.h>
#include<time.h>
#include<string.h>
#include<stdlib.h>
typedef struct
{
char provider_name[15];
int id;
} mob_provider;
mob_provider provider[3]={
{"BSNL",1},{"Idea",2},{"Vodafone",3}};

typedef struct
{
char provider_name[15];
int id;
} dth_provider;

dth_provider dt_provider[3]={ {"Sun


Direct",1},{"DishTV",2},{"Tata Sky",3}};

typedef struct
{
char mobtype[50];
int id;
}data;
data d[10]={ {"DATA
RECHARGE",1},{"MOBILE
RECHARGE",2},{"DTH RECHARGE",3} };

typedef struct
{
int prov_id;
int typeid;
int type; // 1 - top-up , 2- flexi
char mobno[20];
int amt;
}mobile;

typedef struct
{
int provider_id;
char cardno[15];
int amt;
}dth;
dth dt;

mobile mob;
void valid(char);
void typemob(void);
int len,pin,i,n;
int bal=1000;
char c;
void main()
{
//int i,pin;

FILE *fp;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime);
timeinfo=localtime( &rawtime);
do
{
printf("Select your recharge type\n");
for(i=0;i<3;i++)
printf("%d : %s\n",d[i].id,d[i].mobtype);
printf("\nSelect : ");
scanf("%d",&mob.typeid);

if(mob.typeid==1)
{
printf("\nSelect Your provider : \n");
for(i=0;i<3;i++)
{
printf("%d :
%s\n",provider[i].id,provider[i].provider_nam
e);

}
printf("\nSelect : ");
scanf("%d",&mob.prov_id);

typemob();
valid('D');
}

else if(mob.typeid==2)
{
printf("\nSelect Your provider : \n");
for(i=0;i<3;i++)
{
printf("%d :
%s\n",provider[i].id,provider[i].provider_nam
e);

}
printf("\nSelect : ");
scanf("%d",&mob.prov_id);

typemob();
valid('M');
}
else if(mob.typeid==3)
{
if(bal>200)
{

printf("\nSelect Your provider : \n");


for(i=0;i<3;i++)
{
printf("%d :
%s\n",dt_provider[i].id,dt_provider[i].provider
_name);

}
scanf("%d", &dt.provider_id);
printf("Enter the 16 digit number\n");
scanf("%s", dt.cardno);
n=strlen(dt.cardno);
printf("Enter the amount \n");
scanf("%d",&dt.amt);
if(n==16)
{
sleep(5);
fflush(stdout);

printf("\nDTH Recharged successfully\n");


fp=fopen("dth.db", "a");
if(fp == NULL)
exit(-1);
fprintf(fp,"%d ",dt.provider_id);
fprintf(fp,"%s ",dt.cardno);
fprintf(fp,"%d ",dt.amt);
fprintf(fp,"%s",asctime(timeinfo));
fclose(fp);

}
else
{
printf("Please enter a valid card
number\n");
}

}
else
{
printf("\n You dont have enough
balance\n");
} }

printf("\nDo you want to recharge again?\n");


scanf(" %c",&c);

}
while(c=='y'||c=='Y');

void valid(char choice)


{

FILE *fp;
time_t rawtime;
struct tm * timeinfo;
time ( &rawtime);
timeinfo=localtime( &rawtime);

if(len==10)
{
printf("\nEnter the amount\n");
scanf("%d",&mob.amt);
bal=bal-mob.amt;
if(bal>100)
{
pin :
printf("\nEnter PIN\n");
scanf("%d",&pin);
if( pin == 1430)
{
printf("\nProcessing Payment");
sleep(5);
fflush(stdout);
printf("\nDone\n");
fp=fopen("mobile.db", "a");
if(fp == NULL)
exit(-1);
fprintf(fp,"%c ",choice);
fprintf(fp,"%d ",mob.prov_id);
fprintf(fp,"%s ",mob.mobno);
fprintf(fp,"%d ",mob.amt);
fprintf(fp,"%s",asctime(timeinfo));
fclose(fp);
}
else
{
printf("\nInvalid PIN !");
goto pin;
}

}
if(bal==100&&bal<100)
printf("Not sufficient balance\n");
}
else
{
printf("Please enter a valid number :.\n");
typemob();
}
}
void typemob()
{
printf("\nEnter your mobile number\n");
scanf("%s",mob.mobno);
len=strlen(mob.mobno);
}
RESULT
Select your recharge type
1: DATA RECHARGE
2: MOBILE RECHARGE
3: DTH RECHARGE

Select: 2
Select Your provider:
1: BSNL
2: Idea
3: Vodafone

Select: 1
Enter your mobile number
9868577345
Enter the amount
599
Enter PIN
1430
Processing Payment
Done

You might also like