简单模拟银行ATM取款系统

简单模拟银行ATM取款系统

学习C#,第一次C#实验课,模拟ATM取款系统,锻炼基本的C#语法以及选择控制语句!

实现功能:

1.取款 2.余额查询 3.修改密码 4.退出
[cpp]

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace class1
{
class Program
{
static void Main(string[] args)
{
int count = 0;
string pwd = “123456”; int total = 1000;
System.Console.WriteLine(“请输入您的银行卡密码:”);
string s = System.Console.ReadLine();
while (true)
{
if (s == pwd)
{
System.Console.WriteLine(“密码输入正确!3秒后进入系统”);
System.Threading.Thread.Sleep(1000);
Console.Clear();
while (true)
{
Console.WriteLine(“********************************************”);
Console.WriteLine(“********************************************”);
Console.WriteLine(“*********欢迎进入XX银行取款系统*************”);
Console.WriteLine(“**选项:*************************************”);
Console.WriteLine(“**1.取款 2.余额查询 3.修改密码 4.退出*******”);
string choose = Console.ReadLine();
switch (choose)
{
case “1”:
Console.Write(“请输入您的取款金额:”);
int qukuan = int.Parse(Console.ReadLine());
if (qukuan <= total – 10)
{
total -= qukuan;
Console.WriteLine(“本次取款:{0}元,取款成功!”,qukuan);
}
else
Console.WriteLine(“您的余额不足!”);
break;
case “2”:
Console.WriteLine(“余额:{0}”, total); break;
case “3”:
Console.Write(“请输入新的密码:”);
s = Console.ReadLine();Console.WriteLine(“密码修改成功!”); break;
case “4”:
Console.Write(“退出系统!”); System.Environment.Exit(0);break;
}
Console.Write(“按任意键继续!”);
Console.ReadKey(true);
Console.Clear();
}
}
else
{
count++;
System.Console.WriteLine(“密码错误!重新输入:”);
}
if (count == 3) break;
s = System.Console.ReadLine();
}
}
}
}

[/cpp]

One Reply to “简单模拟银行ATM取款系统”

  1. 佩服佩服,很好的博客,我喜欢