(急)!C语言程序设计题---银行帐户管理系统

kuaidi.ping-jia.net  作者:佚名   更新日期:2024-07-24
银行存取款管理系统[C语言编写]

我也想问 可以帮帮忙吗

问题不太清晰。

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>

#define BUFFERSIZE 1024
#define MAXACCOUNT 1000
typedef struct BankAccount
{
int account;
int key;
char name[32];
float balance;
}BANKACCOUNT;

BANKACCOUNT accountCollection[MAXACCOUNT];
int curAccount = 0;

void InsertAccount(FILE *fp)
{
BANKACCOUNT newaccount;
printf("please input the account information\n");
printf(">>account num:");
scanf("%d",&(newaccount.account));
printf(">>key:");
scanf("%d",&(newaccount.key));
printf(">>name:");
scanf("%s",newaccount.name);
printf(">>balance:");
scanf("%f",&(newaccount.balance));
fseek(fp,0L,SEEK_END);
fprintf(fp,"%d %d %s %.2f\n",newaccount.account,newaccount.key,newaccount.name,newaccount.balance);
}
void GetAccount(FILE *fp)
{
int accountnum;
int key;
char name[32];
float balance;
int i =0,j;
char buffer[BUFFERSIZE];
int len;
curAccount = 0;
fseek(fp,0,SEEK_SET);
while(!feof(fp)) /* 因为feof()最后会读2遍,所以最后curAccount多加了1 */
{
fscanf(fp,"%d %d %s %f",&accountnum,&key,name,&balance);
accountCollection[curAccount].account = accountnum;
accountCollection[curAccount].key = key;
strcpy(accountCollection[curAccount].name ,name);
accountCollection[curAccount].balance = balance;
curAccount++;
}
}
void ListAccount(FILE *fp)
{
int i =0;
printf("There is %d accounts at all:\n",curAccount-1);/* curAccount减去多加的1 */
for(i = 0;i< curAccount-1;i++)
{
printf("ACCOUNT[%d]:\n",i+1);
printf("account:%d\n",accountCollection[i].account);
printf("name:%s\n",accountCollection[i].name);
printf("balance:%.2f\n",accountCollection[i].balance);
}
}
int SearchAccount(FILE *fp,int accountnum)
{
int i =0;
for(i = 0;i< curAccount-1;i++)
{
if(accountCollection[i].account == accountnum)
{
printf("ACCOUNT[%d]:\n",i+1);
printf("account:%d\n",accountCollection[i].account);
printf("name:%s\n",accountCollection[i].name);
printf("balance:%.2f\n",accountCollection[i].balance);
return 1;
}
}
return 0;
}
void DelAccount(FILE *fp,int accountnum)
{
int i;
if(SearchAccount(fp,accountnum)==0)
printf("Can't find the account\n");
else
{
for(i = 0;i<curAccount-1;i++)
{
if(accountCollection[i].account != accountnum)
fprintf(fp,"%d %d %s %.2f\n",accountCollection[i].account,accountCollection[i].key,accountCollection[i].name,accountCollection[i].balance);
}
printf("delete successfully!\n");
}
}

int main()
{
FILE *fp;
int accountnum;
int i;
do{
system("cls"); //清屏
puts("********************************************");
puts("* You can choose : *");
puts("* 1 : Insert a new Account *");
puts("* 2 : List all Accounts *");
puts("* 3 : Find a Account *");
puts("* 4 : Delete a Account *");
puts("* 5 : quit *");
puts("********************************************");
printf("Please input your choice:");
scanf("%d",&i);
system("cls"); //清屏
switch(i)
{
case 1:
if(!(fp = fopen("account.txt","a+")))
{
printf("can't open the file account.txt\n");
exit(0);
}
InsertAccount( fp);

printf("press any key to continue.....\n");
getch();
fclose(fp);
break;
case 2:
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
ListAccount(fp);

fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
case 3:
printf("please input the account num:\n");
scanf("%d",&accountnum);
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
if(!SearchAccount(fp,accountnum))
printf("There is not the account:%d\n",accountnum);

fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
case 4:
printf("please input the account num:\n");
scanf("%d",&accountnum);
if(!(fp = fopen("account.txt","r")))
{
printf("can't open the file account.txt\n");
exit(0);
}
GetAccount(fp);
fclose(fp);
if(!(fp = fopen("account.txt","w+")))
{
printf("can't open the file account.txt\n");
exit(0);
}
DelAccount(fp,accountnum);
fclose(fp);
printf("press any key to continue.....\n");
getch();
break;
default:
break;
}
}while(i != 5);
return 0;
}

这里账户数据文件名已经设定为account.txt,这个文件要和上面这个程序放在同一个文件夹下面,不然就得用绝对路径(比如"d:\\book\\account.txt"),account内容可以用记事本打开自己改动,然后运行程序后就可以在程序中添加或删除。account.txt一个参考内容如下:
1 10023 zhangsl 100.50
2 32001 sunq 5000.00
3 20010 wangxi 2500.00 4

已将程序发至邮箱

最讨厌的是叫别人代写一大段代码了,我只想说,这东西,求人求天,不如求自己。除非拿rmb,否则很少会有人会为了那么几个金币去写的。

  • (急)!C语言程序设计题---银行帐户管理系统
    答:include<stdio.h> include<stdlib.h> include<string.h> include<conio.h> define BUFFERSIZE 1024 define MAXACCOUNT 1000 typedef struct BankAccount { int account;int key;char name[32];float balance;}BANKACCOUNT;BANKACCOUNT accountCollection[MAXACCOUNT];int curAccount = 0;void InsertAccoun...
  • 求C语言程序设计(银行ATM取款机)
    答:终于编写出来了 include<stdio.h> void main(){ char SelectKey,CreditMoney,DebitMoney;while(1){ do{ clrscr();puts("Please select key:");puts("1.Quary");puts("2.Credit");puts("3.Debit");puts("4.Return");SelectKey=getch();}while(SelectKey!='1'&&SelectKey!='2'&&SelectKey!
  • c语言程序设计,和银行存款利率有关的问题
    答:include<StdAfx.h> include<stdio.h> include <conio.h> include <math.h> int main(){ float rate=0,capital=0,deposit=0;int n=0;printf("请输入本金,利率,存款期限:");scanf("%f,%f,%d",&capital,&rate,&n);deposit = capital * pow((1+rate),n);printf("本利共计:%.2f\n"...
  • 急求一个C语言编写的银行存取款管理设计的程序。
    答:include<iostream>#include<cstring>using namespace std;class count{public:friend class ATM;count (char Name[],char Num[],floatMoney,char Password[]); //初始化protected:char * get_name(); //返回姓名char * get_num(); //返回卡号char * get_password(); //返回密码float get_mone...
  • C语言小程序.写一个关于银行存取钱的
    答:do{ printf("请选择:D(存款);W(取款);F(结束).\n"); fflush(stdin); choice = getchar(); switch(choice) { case 'D': case 'd': scanf("%f",&withdraw); balance += withdraw; break; case 'W': case '...
  • c语言问题:请你给银行的柜员机写一个硬币兑换计算程序?
    答:那就修改为这样(要说清楚是OJ啊):include<stdio.h> int main(){ int a,b,c,x;scanf("%d%d%d",&a,&b,&c);x=10*a+5*b+c;printf("%d %d %d\n",x/100,x%100/10,x%10);return 0;}
  • 银行存款的C语言编程问题
    答:int n;float y=0.0175*x,sum;for(n=1;n<15;n++){x+=0.08*xy+=0.175*x;}printf("存入现金%f,可得利息%f,它们之和%f",12*x,12*y,12*(x+y));}int main(){printf("其多余的钱是第一年每月2000元,以后每年每月多余的钱在上一年队每月多余钱的基础上再增加8%,活期月息为0....
  • C语言编程题目 实现银行的电子排队业务 急~
    答:typedef struct node { int num;char name[20];}LNode;LNode QUEUE[20];int front=0;int rear=0;int i=0;int main(){ int MAINX(LNode QUEUE[20]/*,int front,int rear*/); //改动 MAINX(QUEUE/*,front,rear*/);//改动 return 0;} int MAINX(LNode QUEUE[20]/*,int front...
  • 编写一个C语言程序模拟银行ATM机的账户管理功能,系统主要实现以下功能...
    答:include <string.h> define AN 9 //表示账号8位 define PN 7 //表示密码6位 define ASN 3 //表示系统中共有3个账户信息 struct Account { char accountnumber[AN]; //表示账号信息 char password[PN]; //表示账户的密码信息 double balance; //表示账户的余额 };struct Account ats[ASN]=...
  • 用c语言如何写一个银行存取款管理设计
    答:3、进一步要求:完成客户姓名查询存款和取款记录,并能得到每次帐户总金额。要求:1、用C语言实现系统;2、利用结构体数组实现信息的数据结构设计;3、系统的各个功能模块要求用函数的形式实现;4、界面友好(良好的人机交互),程序加必要的注释。课程设计实验报告要求:1、预习报告:题目、课程设计任务、...