在我們的高級的需求,我們被要求創建用戶在其中輸入,並得到他/她的儲蓄信息細節的應用...控制檯應用程序異常
其工作完全正常, 除了事實當我按Enter鍵時,我得到一個異常和我的程序崩潰..
請提供我的信息,以便在我的控制檯應用程序,即使我按Enter鍵,我沒有得到異常,而是,它返回的程序。
非常感謝, 非常感謝。
這是我的程序。
using System;
using System.Collections.Generic;
using System.Text;
namespace bankprob {
class sav_acc
{
public float amount;
public sav_acc(float amount)
{
this.amount = amount;
}
public void getdeposit(float depos)
{
amount += depos;
}
public void display()
{
Console.WriteLine("Balance of Customer :{0} ", amount);
}
public void withdrawl(float amt)
{
amount =amount - amt;
}
public void minbal()
{
if (amount < 1000)
{
Console.WriteLine("You cannot withdraw beyond the minimum balance of rupees 1000. ");
return;
}
}
}
class cur_acc
{
public float amount = 0;
public cur_acc(float amount)
{
this.amount = amount;
}
public void getdeposit(float depos)
{
amount += depos;
}
public void display()
{
Console.WriteLine("Balance of Customer : {0}", amount);
}
public void withdrawl(float amt)
{
amount = amount - amt;
}
public void minbal()
{
if (amount < 1000)
{
Console.WriteLine(" Your balance is less than 1000, and u cannot make any withdrawals");
}
else
Console.WriteLine("Balance is greater than Rs 1000 no need to panality");
}
}
class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Welcome Mr.Sayeed");
Console.WriteLine("Please select the type of account.\n1.Savings 2.Current 3.Exit");
int ch;
ch = int.Parse(Console.ReadLine());
switch (ch)
{
case 1:
Console.WriteLine("Enter Initail Amount : ");
float amt = int.Parse(Console.ReadLine());
sav_acc s = new sav_acc(amt);
Console.WriteLine("Enter deposit money : ");
float depos = float.Parse(Console.ReadLine());
s.getdeposit(depos);
s.display();
Console.WriteLine("Enter withdrawl Amount");
float wamt = float.Parse(Console.ReadLine());
s.withdrawl(wamt);
s.display();
s.minbal();
s.display();
break;
case 2:
Console.WriteLine("Enter Initail Amount : ");
float am = int.Parse(Console.ReadLine());
cur_acc c = new cur_acc(am);
Console.WriteLine("Enter deposit money : ");
float depo = float.Parse(Console.ReadLine());
c.getdeposit(depo);
c.display();
Console.WriteLine("Enter withdrawl Amount");
float wam = float.Parse(Console.ReadLine());
c.withdrawl(wam);
c.display();
c.minbal();
c.display();
break;
case 3:
Console.WriteLine("Thank you for Using this applicaton");
return;
default:
Console.WriteLine("You have made a wrong choice, Thank you...");
return;
}
}
}
}
當拋出異常時,您可以讀取異常的消息以及查看異常的堆棧跟蹤。應該幫助你解決這樣的問題。如果你仍然不明白問題是什麼,那麼至少應該在你的問題中包含這些信息。 – 2012-04-14 11:47:36
這是一個家庭作業嗎?你應該給它一個適當的標籤。 – Turbot 2012-04-14 14:25:46