您的位置:首页 > 编程语言 > C#

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

2010-05-14 14:51 411 查看
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]);

        }

    }

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c# string class
相关文章推荐