用C#编写的银行取款系统

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Inten
{
class Data
{
st S = new st();
int x = 0;
public void hello()
{
Console.WriteLine("**********************************");
Console.WriteLine("**********************************");
Console.WriteLine("*****欢迎使用工商银行存取款机*****");
Console.WriteLine("**********************************");
Console.WriteLine("**********************************");
Username();

}

private void Username()
{
S.Username=new string[3];
S.Username[0] = "zhang";
S.Username[1] = "yi";
S.Username[2] = "gang";
Userpwd();
}

private void Userpwd()
{
S.Userpwd = new string[3];
S.Userpwd[0] = "ZH";
S.Userpwd[1] = "YI";
S.Userpwd[2] = "GA";
Usermoney();
}

private void Usermoney()
{
S.Usermoney = new double[3];
S.Usermoney[0] = 5000;
S.Usermoney[1] = 3000;
S.Usermoney[2] = 1000;
check();
}
//选择进出
private void Land()
{
Console.WriteLine("你确定要退出吗?");
Console.WriteLine("1.是 2.否");
int xn;
xn = Convert.ToInt32(Console.ReadLine());
switch (xn)
{
case 1:
Console.WriteLine("谢谢您光临工商银行存取款机!");
break;
case 2:
QJD();
break;
}
}
//登陆进入
private void check()
{
bool bo = false;
for(int y=0;y<3;y++)
{
Console.WriteLine("请输入用户名:");
string name = Console.ReadLine();
Console.WriteLine("请输入密码:");
string pwd = Console.ReadLine();
for (; x < S.Username.Length; x++)
{
if (name.Equals(S.Username[x]) && pwd.Equals(S.Userpwd[x]))
{
bo = true;
S.Id = x;
break;
}
}
if (bo)
{
Console.WriteLine("登陆成功!");
//执行应用程序
QJD();
break;
}
else
{
Console.WriteLine("请正确输入!");
}
}
}

private void QJD()
{
while (true)
{
bool bo = false;
Console.WriteLine("**********************************");
Console.WriteLine("*****欢迎使用工商银行存取款机*****");
Console.WriteLine("**********************************");
Console.WriteLine("1.取款 2.存款");
Console.WriteLine("3.转账 4.查询");
Console.WriteLine(" 5.退卡");
int n;
n = Convert.ToInt32(Console.ReadLine());
switch (n)
{
case 1:
//取款
qk();
break;
case 2:
//存款
ck();
break;
case 3:
//转账
zz();
break;
case 4:
//查询
chaxu();
break;
case 5:
//退卡???
Console.WriteLine("谢谢您的光临!");
bo = true;
break;
Land();

}
if (bo)
{
break;
}
else
{
continue;
}
}
}

//1.取款
private void qk()
{
Console.WriteLine("请输入你要取款的金额:");
double nx = Convert.ToDouble(Console.ReadLine());
if (nx > S.Usermoney[S.Id])
{
Console.WriteLine("你的余额不足!");
QJD();
}
S.Usermoney[S.Id] = S.Usermoney[S.Id] - nx;
}
//2.存款
private void ck()
{
Console.WriteLine("请输入你要存款的金额:");
double nx = Convert.ToDouble(Console.ReadLine());
S.Usermoney[S.Id] = S.Usermoney[S.Id] + nx;
}
//3.转账

private void zz()
{
//Console.WriteLine("请输入你要转账的账号:");
//string name = Console.ReadLine();
//if (name.Equals(S.Username))
//{
// Console.WriteLine("请输入你要转账的金额:");
// double num = Convert.ToDouble(Console.ReadLine());
// if (num > S.Usermoney[S.Id])
// {
// Console.WriteLine("您的余额不足!");
// QJD();
// }
// else
// {
// S.Usermoney[S.Id] = S.Usermoney[S.Id] - num;
// S.Usermoney[name] = S.Usermoney[name] + num;
// }
//}
}
//4.查询
private void chaxu()
{
Console.WriteLine("你的余额:"+S.Usermoney[S.Id]);
}
}
}

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值