0
我是新來的c#,我試圖打印收據,但我的代碼無法正常工作。這裏是我的問題:控制檯應用程序,C#收據程序
計算價格乘以用戶
計算上述款額規定的量 - 12%的稅顯示的增值稅接受金錢和
計算改變他們必須全部出現一旦單位價格已輸入
這是我的代碼在這一刻的計算部分
bool test = false;
do
{
try
{
Console.SetCursorPosition(2, 12);
Console.Write(" ");
Console.SetCursorPosition(2, 12);
Num = Convert.ToInt32(Console.ReadLine());
test = false;
}
catch
{
test = true;
}
} while (test);
Console.SetCursorPosition(18, 12);
Console.ForegroundColor = ConsoleColor.Yellow;
telNumber = Console.ReadLine();
//Peso
bool Ptest = false;
do
{
try
{
Console.SetCursorPosition(47, 12);
Console.Write(" ");
Console.SetCursorPosition(47, 12);
Amount = Convert.ToInt32(Console.ReadLine());
Console.SetCursorPosition(65, 12);
Amount = Amount * 2 ;
Console.WriteLine("P " + Amount.ToString("0.00"));
Console.SetCursorPosition(65, 15);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("P " + Amount.ToString("0.00"));
Console.SetCursorPosition(65, 17);
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("P " + Amount.ToString("0.00"));
Ptest = false;
}
catch
{
Ptest = true;
}
} while (Ptest);
//Amount
Console.ReadLine();
它看起來像這樣,我已經做了格式,但我在上面所說的問題的麻煩,請幫整數
那到底是什麼不工作?您已經說明了您希望程序執行的操作,但是不要指出哪個位會給您帶來麻煩。 – 2014-12-08 04:24:16
我不能做計算先生,我的代碼只接受整數,但我無法計算稅額和總金額。請參閱提供的圖像,我似乎無法得到正確的計算結果,這是正確的程序 – Puchicha 2014-12-08 04:28:27
您將永遠不會使用整數獲得小數值,請嘗試使用Decimal類型。 – 2014-12-08 04:32:47