namespace ConsoleApp2
{
class Money
{
private int dollars;
private int cents;
public int Dollars
{
get { return dollars; }
set
{
if (value > 0)
dollars = value;
}
}
public int Cents
{
get { return cents; }
set
{
if (value > 0)
cents = value;
}
}
public Money(int D, int C)
{
Dollars = 5;
Cents = 36;
}
public int ConvertToOne()
{
int Total;
Total = Dollars + (Cents / 100);
return Total;
}
public int IncrementMoney()
{
int IncAmmount;
int NewBalance;
Console.WriteLine("Enter decrement amount.");
Console.WriteLine("Enter full dollar and cent amount: ");
IncAmmount = int.Parse(Console.ReadLine());
NewBalance = Total + IncAmmount;
}
static void Main(string[] args)
{
int DecAmmount;
Console.WriteLine("Welcome to the money exchange by Jason Rebelo");
Console.WriteLine("Original Ammount" + "Dollars: " + dollars);
Console.WriteLine("Cents:" + cents);
DecAmmount = Console.Reaadline();
}
}
}
我觉得我错过了继续使用此代码的重要内容...我不知道如何在ConvertToOne
中使用IncrementMoney
方法中的Total。
我正在做一个控制台应用程序,它应该提供以下信息
原始金额; 美元:5 美分:36
输入减量金额。 输入完整美元和分数:3.00(由用户输入)
原始金额:$ 5.36
减量测试: 减去金额:3.00 新元金额:2.00 新分金额:.36等