当前位置: 首页>>代码示例>>C#>>正文


C# Receipt.returnMTotal方法代码示例

本文整理汇总了C#中Receipt.returnMTotal方法的典型用法代码示例。如果您正苦于以下问题:C# Receipt.returnMTotal方法的具体用法?C# Receipt.returnMTotal怎么用?C# Receipt.returnMTotal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Receipt的用法示例。


在下文中一共展示了Receipt.returnMTotal方法的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;
        }
开发者ID:Blurpy-the-RABID,项目名称:ReceiptCalculator,代码行数:56,代码来源:Interface.cs


注:本文中的Receipt.returnMTotal方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。