ATM机(1)


学习C#,没有入门多久,虽然刚开始学过,但是一直陆陆续续,学的不怎么坚持,这回有努力学,刚学习完函数的调用,展示一下小小的成果。虽然还没有连接数据库,但是效果还是有的,多多加油哈~~

创建ATM机,未连接数据库
  1 using System;
  2 public class ATM
  3 {
  4     public static string name = "";
  5     public static string pwd = "";
  6     public static string Rname = "";
  7     public static string Rpwd = "";
  8     public static string Idnum = "";
  9     public static string Phone = "";
 10     public static double money = 0.00;
 11     public static double month = 0.00;
 12     public static string result = "";
 13 
 14     public static void Main()
 15     {
 16         Menu();
 17     }
 18 /*----------------------------------------------------------------------------*/
 19     public static void Menu()
 20     {
 21         Console.WriteLine("------------- 欢迎使用建设银行ATM------------");
 22         Console.WriteLine("1.\t 注册");
 23         Console.WriteLine("2.\t 登录");
 24         Console.WriteLine("3.\t 退出");    
 25         result = Console.ReadLine();
 26         if (result == "1")
 27         {
 28             Register();
 29         }
 30         if (result == "2")
 31         {
 32             Login();
 33         }
 34         if (result == "3")
 35         {
 36         
 37         }
 38     }
 39 /*----------------------------------------------------------------------------*/
 40     public static void Register()
 41     {
 42         Console.WriteLine("1.\t 请输入注册用户名:");
 43         Rname = Console.ReadLine();
 44         Console.WriteLine("2.\t 请输入身份证号:");
 45         Idnum = Console.ReadLine();
 46         Console.WriteLine("3.\t 请输入联系电话:");
 47         Phone = Console.ReadLine();
 48         Console.WriteLine("4.\t 请输入注册密码:");
 49         Rpwd = Console.ReadLine();
 50         Console.WriteLine("5.\t 请确认注册密码:");
 51         Rpwd = Console.ReadLine();    
 52         if (Rname != ""&&Idnum != ""&&Phone != ""&&Rpwd != "")
 53         {
 54             Console.WriteLine("注册成功!");
 55             Suclogin();
 56         }
 57         else                
 58         {
 59             Console.WriteLine("注册失败!");
 60             Register();
 61         }
 62     }
 63 /*----------------------------------------------------------------------------*/
 64     public static void Login()
 65     {
 66         Console.WriteLine("1.\t 请输入用户名:");
 67         name = Console.ReadLine();
 68         Console.WriteLine("2.\t 请输入密码:");
 69         pwd = Console.ReadLine();
 70         if (name != ""&&pwd != "")
 71         {
 72             Console.WriteLine("登录成功!");
 73             Suclogin();
 74         }
 75         else                
 76         {
 77             Console.WriteLine("登录失败!");
 78             Login();
 79         }
 80     }
 81 /*----------------------------------------------------------------------------*/
 82     public static void Suclogin()
 83     {
 84         Console.WriteLine("------------- 欢迎建设银行ATM服务菜单------------");
 85         Console.WriteLine("1.\t 查询");
 86         Console.WriteLine("2.\t 存款");
 87         Console.WriteLine("3.\t 取款");    
 88         Console.WriteLine("4.\t 利息查询");    
 89         Console.WriteLine("5.\t 退出");
 90         result = Console.ReadLine();
 91         if (result =="1")
 92         {
 93             Research();
 94         }
 95         if (result =="2")
 96         {
 97             Deposit();
 98         }
 99         if (result =="3")
100         {
101             Take();
102         }
103         if (result =="4")
104         {
105             Interest();
106         }
107         if (result =="5")
108         {
109             Menu();
110         }
111 
112     }
113 /*----------------------------------------------------------------------------*/
114     public static void Deposit()
115     {
116         Console.WriteLine("------------- 欢迎建设银行ATM存款服务菜单------------");
117         Console.WriteLine("1.\t 活期");
118         Console.WriteLine("2.\t 定期");
119         Console.WriteLine("3.\t 投资");    
120         Console.WriteLine("4.\t 返回");    
121         result = Console.ReadLine();
122         if (result =="1")
123         {
124             Live();
125         }
126         if (result =="2")
127         {
128             Regular();
129         }
130         if (result =="3")
131         {
132             Invest();
133         }
134         if (result == "4")
135         {
136             Menu();
137         }
138 
139     }
140     /*--------------------------------------------------*/
141     public static void Live()
142     {
143         Console.WriteLine("1.\t 请输入存款金额:");
144         money = Convert.ToDouble(Console.ReadLine());
145         Console.WriteLine("2.\t 请输入存入时间[以月为单位]:");
146         double month = Convert.ToDouble(Console.ReadLine());
147         Suclogin();
148     }
149     /*--------------------------------------------------*/
150     public static void Regular()
151     {
152         Console.WriteLine("1.\t 请输入存款金额:");
153         money = Convert.ToDouble(Console.ReadLine());
154         Console.WriteLine("2.\t 请输入存入时间[以年为单位]:");
155         double month = Convert.ToDouble(Console.ReadLine());
156         Suclogin();
157 
158     }
159     /*--------------------------------------------------*/
160     public static void Invest()
161     {
162         double inve = 0.00;
163         Console.WriteLine("\t 请输入投资金额:");
164         inve = Convert.ToDouble(Console.ReadLine());
165         if (inve <100000.00)
166         {
167             Console.WriteLine("金额过少,不予受理!");
168         }
169         else 
170         {
171             inve = inve*0.05 ;
172             Console.WriteLine("您将获得利息:" + inve);
173         } 
174         Suclogin();
175     }
176 /*----------------------------------------------------------------------------*/
177     public static void Take()
178     {
179         
180         Console.WriteLine("------------- 欢迎建设银行ATM取款服务菜单------------");
181         Console.WriteLine("\t 请输入取款金额:");
182         Console.WriteLine("1.\t 100.00");
183         Console.WriteLine("2.\t 200.00");
184         Console.WriteLine("3.\t 500.00");    
185         Console.WriteLine("4.\t 1000.00");    
186         Console.WriteLine("5.\t 5000.00");
187         Console.WriteLine("6.\t 10000.00");
188         result  = Console.ReadLine();
189         if (result == "1")
190         {
191             if (money <100.00)
192             {
193                 Console.WriteLine("余额不足,取款失败!");
194             }
195             else
196             {
197               money = money -100.00;
198               Console.WriteLine("余额:"+ money +"");
199             }
200         }
201         
202         if (result == "2")
203         {
204             if (money <200.00)
205             {
206                 Console.WriteLine("余额不足,取款失败!");
207             }
208             else
209             {
210             money = money - 200.00;
211             Console.WriteLine("余额:"+ money +"");
212             }
213         }
214         if (result == "3")
215         {
216             if (money< 500.00)
217             {
218                 Console.WriteLine("余额不足,取款失败!");
219             }
220             else
221             {        
222             money = money-500.00;
223             Console.WriteLine("余额:"+ money +"");
224             }
225         }
226         if (result == "4")
227         {
228             if (money<1000.00)
229             {
230                 Console.WriteLine("余额不足,取款失败!");
231             }
232             else
233             {        
234             money = money-1000.00;
235             Console.WriteLine("余额:"+ money +"");
236             }
237         }
238         if (result == "5")
239         {
240             if (money<5000.00)
241             {
242                 Console.WriteLine("余额不足,取款失败!");
243             }
244             else
245             {        
246             money = money-5000.00;
247             Console.WriteLine("余额:"+ money +"");
248             }
249         }
250         if (result == "6")
251         {
252             if (money <10000.00)
253             {
254                 Console.WriteLine("余额不足,取款失败!");
255             }
256             else
257             {        
258             money = money - 10000.00;
259             Console.WriteLine("余额:"+ money +"");
260             }
261         }
262         Suclogin();
263 
264     /*    Console.WriteLine("2.\t 请输入存入时间[以月为单位]:");
265         double month = Convert.ToDouble(Console.ReadLine());
266         double inter = double operator *((double operator *(money,2.85)%),(double operator /(month,12)));
267         Console.WriteLine(inter);  */
268     }
269 /*----------------------------------------------------------------------------*/
270     public static void Interest()
271     {
272         Console.WriteLine("1.\t 请输入金额:");
273         Console.ReadLine();
274         Console.WriteLine("2.\t 请输入存入时间[以月为单位]:");
275          month =Convert.ToDouble(Console.ReadLine());
276         double inter = 0.00;
277         inter = money * 0.0285 *(month /12);
278         Console.WriteLine("您将获得利息:" + inter); 
279         Suclogin();
280     } 
281 /*----------------------------------------------------------------------------*/
282     public static void Research()
283     {
284         Console.WriteLine("您的用户名:"+name);
285         //Console.WriteLine("");
286         Console.WriteLine("您的余额:"+money +"");
287         Suclogin();
288     }
289 
290 }

转载于:https://www.cnblogs.com/zyh-bg/archive/2012/08/08/2629078.html

你可能感兴趣的:(数据库,c#)