class Program
{
static void Main()
{
double pricePerBar;
int casesSold;
Console.Write("The amount of profit made on the granola sales will be displayed.\n" +
"First you will be asked to enter the sale price per granola bar.\n" +
"Then you will be asked to enter the number of cases of granola bars sold. \n\n\n");
pricePerBar = GetDouble("price per bar");
casesSold = GetInteger("number of cases sold");
double netSales = NetSales(casesSold, GrossSales(pricePerBar, BarsSold(casesSold)));
double netProfit = NetProfit(netSales, GovFeeDue(netSales));
DisplayResults(netProfit);
}
static int BarsSold(int casesSold)
{
int BARS_PER_CASE = 12;
return casesSold * BARS_PER_CASE;
}
static double GrossSales(double price, int BarsSold)
{
return price * BarsSold;
}
static double NetSales(double casesSold, double grossSales)
{
const double WHOLESALE_COST_PER_CASE = 5.00;
return grossSales - (casesSold * WHOLESALE_COST_PER_CASE);
}
static double GovFeeDue(double netSales)
{
double fee_rate = 0.10;
return fee_rate * netSales;
}
static double NetProfit(double netSales, double govFeeDue)
{
return netSales - govFeeDue;
}
static void DisplayResults(double profit)
{
Console.WriteLine("Net Profit:{0:C}", profit);
Console.ReadLine();
}
static int GetInteger(string wantedInfo)
{
return Convert.ToInt32(GetInfo(wantedInfo));
}
static double GetDouble(string wantedInfo)
{
return Convert.ToDouble(GetInfo(wantedInfo));
}
static string GetInfo(string wantedInfo)
{
string inputValue;
Console.Write("\nPlease enter the {0}: ", wantedInfo);
inputValue = Console.ReadLine();
return inputValue;
}
}
Did you convert this from VB? Remember that C# is case sensitive and you seenm to have cases pretty mixed up. Also, C# treats functions slightly differently and you don't need to declare the return values if you are not using them for any other purpose.
I did not add any error checking - consider how to handle the user entering alpha characters or a ridiculously high number. Neither did I change your logic but I think you could simplify the implementation of your algorithm.
Another thing to look at is the way you hard-code constants. What if the wholesale cost changes or the goverment fee rate goes up? What do you think you could do so that you wouldn't have to change the program if either of these things happened?