C# 我的程序计算错了吗?

C# 我的程序计算错了吗?,c#,C#,所以在我的C班上,我被要求 编写一个程序,计算计算机俱乐部将从格兰诺拉麦片酒吧销售项目的收益中获得的金额。允许用户输入已售出的箱子数量和每根棒材的售价。每个箱子包含12根棒材;每箱从当地供应商处以每箱5.00美元的价格购买。俱乐部需要向学生政府协会提供其收入的10%。显示他们用货币格式化的收益。为您的解决方案编写适当的方法 我写了这个程序,但我很确定,除非我把我插入计算器的计算结果搞砸了,否则数学不会加起来。 这是我的密码 using System; namespace GranolaBars

所以在我的C班上,我被要求

编写一个程序,计算计算机俱乐部将从格兰诺拉麦片酒吧销售项目的收益中获得的金额。允许用户输入已售出的箱子数量和每根棒材的售价。每个箱子包含12根棒材;每箱从当地供应商处以每箱5.00美元的价格购买。俱乐部需要向学生政府协会提供其收入的10%。显示他们用货币格式化的收益。为您的解决方案编写适当的方法

我写了这个程序,但我很确定,除非我把我插入计算器的计算结果搞砸了,否则数学不会加起来。 这是我的密码

using System;

namespace GranolaBars
{
    class Granola
    {
        static void Main(string[] args)
        {
            // Give user info on program
            Console.WriteLine("The Computer Club buys the cases at $5.00 a case");
            Console.WriteLine("The studdent government gets 10% of profit");
            Console.WriteLine("Total made from sell is number of cases sold minus 10%");

            // Declare the variables
            int casesSold;
            decimal pricePerBar;
            decimal profit;
            decimal proceeds;
            decimal finalOutCome;

            // Set the variables values
            casesSold = GetCasesSold();
            pricePerBar = GetPricePerCase();
            profit = GetProfit(casesSold, pricePerBar);
            proceeds = GetProceeds(profit);
            finalOutCome = GetFinalOutCome(proceeds, profit);

            // The output from the program 
            Console.WriteLine("The amount cases of sold was: {0} ", casesSold);
            Console.WriteLine("The price per bar was {0:C}: ", pricePerBar);
            Console.WriteLine("The gross profit is: {0:C}: ", profit);
            Console.WriteLine("The student government fees are: {0:C} ", proceeds);
            Console.WriteLine("The income minus the student government fees is: {0:C} ", finalOutCome);

            Console.ReadKey();
    }
    public static int GetCasesSold()
    // Method that gets the total number of cases sold
    {
        int CSold;
        Console.Write("Enter the number of cases sold: ");
        CSold = int.Parse(Console.ReadLine());
        return CSold;
    }
    public static decimal GetPricePerCase()
    // Method that gets the price per case of garnola bars
    {
        decimal PerBar;
        Console.Write("Enter the price per bar: ");
        PerBar = decimal.Parse(Console.ReadLine());
        return PerBar;
    }
    public static decimal GetProfit(int CasesSold, decimal PricePerBar)
    // Method to get the Profit
    {
        decimal PriceofCase = 5.00M;
        decimal Earnings;
        Earnings = ((PricePerBar * 12) - PriceofCase);
        return Earnings;
    }
    public static decimal GetProceeds(decimal Profit)
    // Method to get the Proceeds
    {
        decimal StudentGovFunds = .10M;
        return (Profit * StudentGovFunds);
    }
    public static decimal GetFinalOutCome(decimal Proceeds, decimal Profit)
    // Method to calculate the final total made from selling granola pars
    {
        return (Profit - Proceeds);
    }
}

我的程序计算正确吗?还是我遗漏了使它计算正确的东西

这似乎是个问题

我的意思是,至少在某一点上,你需要知道多少箱被售出

 public static decimal GetProfit(int CasesSold, decimal PricePerBar)
 // Method to get the Profit
 {
    return (((PricePerBar * 12) - PriceofCase) * CasesSold); 
 }
输出

The Computer Club buys the cases at $5.00 a case
The studdent government gets 10% of profit
Total made from sell is number of cases sold minus 10%
Enter the number of cases sold: 2
Enter the price per bar: 10
The amount cases of sold was: 2
The price per bar was $10.00:
The gross profit is: $230.00:
The student government fees are: $23.00
The income minus the student government fees is: $207.00

使用纸和铅笔。找出一组值的正确答案。使用这些值运行应用程序。如果它们匹配,则是正确的。重复一系列数字。如果没有,请使用。这对我们来说并不是一个真正需要解决的问题。因此,基本上学生会正在运行一个保护组织。所以,请阅读并采取行动。你过去的贡献分数很低。