本文整理汇总了C#中Receipt.getIndivTotal方法的典型用法代码示例。如果您正苦于以下问题:C# Receipt.getIndivTotal方法的具体用法?C# Receipt.getIndivTotal怎么用?C# Receipt.getIndivTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Receipt
的用法示例。
在下文中一共展示了Receipt.getIndivTotal方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getReceiptEntry
// This method will go through the process of acquiring the data for an individual receipt, and then returning the finished receipt.
public Receipt getReceiptEntry(string receiptOwner, int receiptNumber)
{
Receipt receipt = new Receipt(receiptOwner, receiptNumber);
Console.WriteLine("\nReceipt {0}{1}:", receiptOwner, receiptNumber);
Console.Write("Enter Receipt {0}{1}'s Communal Total: ", receiptOwner, receiptNumber);
double communalTotal = Convert.ToDouble(Console.ReadLine());
receipt.getCommunalTotal(communalTotal);
Console.Write("\nAre there any individual items that are not communal? (y/n): ");
string answer = Console.ReadLine().ToUpper();
if (answer == "Y") {
Console.WriteLine("Enter the first initial of the persons to whom the item(s) was bought for (A / V / M).");
Console.Write("If multiple persons have items on this Receipt, separate their initials with a space: ");
string indivItemOwner = Console.ReadLine().ToUpper();
string[] initials = indivItemOwner.Split(' ');
for (int j = 0; j < initials.Length; j++) {
indivItemOwner = initials[j];
switch (initials[j]) {
case "A":
Console.Write("\nEnter the total amount (including tax) that Andy owes for his items on Receipt {0}{1}: ", receiptOwner, receiptNumber);
receipt.getIndivTotal(indivItemOwner, Convert.ToDouble(Console.ReadLine()));
break;
case "V":
Console.Write("\nEnter the total amount (including tax) that Vinny owes for his items on Receipt {0}{1}: ", receiptOwner, receiptNumber);
receipt.getIndivTotal(indivItemOwner, Convert.ToDouble(Console.ReadLine()));
break;
case "M":
Console.Write("\nEnter the total amount (including tax) that Mike owes for his items on Receipt {0}{1}: ", receiptOwner, receiptNumber);
receipt.getIndivTotal(indivItemOwner, Convert.ToDouble(Console.ReadLine()));
break;
default:
Console.WriteLine("Error: Unrecognized first initial.");
break;
}
}
}
// Now we display all of the data entered for the current receipt.
Console.WriteLine("\nReceipt {0}{1}:", receiptOwner, receiptNumber);
Console.WriteLine("Communal Total = {0}", receipt.returnCommunalTotal());
if (receiptOwner == "A") {
Console.WriteLine("Additional Amount Owed By Vince: {0}", receipt.returnVTotal());
Console.WriteLine("Additional Amount Owed By Mike: {0}", receipt.returnMTotal());
}
else if (receiptOwner == "V") {
Console.WriteLine("Additional Amount Owed By Andy: {0}", receipt.returnATotal());
Console.WriteLine("Additional Amount Owed By Mike: {0}", receipt.returnMTotal());
}
else if (receiptOwner == "M") {
Console.WriteLine("Additional Amount Owed By Andy: {0}", receipt.returnATotal());
Console.WriteLine("Additional Amount Owed By Vince: {0}", receipt.returnVTotal());
}
return receipt;
}