Write a program that computes the amount of money the computer club will receive from proceeds of their granola bar sales project.Allow the user to enter the number of cases sold and the sale price per bar.Each case contains 12 bars; each case is purchased at $5.00 per case from a local vendor.The club is required to give the student govern- ment association 10% of their earnings. Display their proceeds formatted with currency. Write appropriate methods for your solution.
**I should also note that I'm not looking for any answers to cheat, because this is an assignment, but I just need some guidance.
- My questions are:
1.) Am I declaring these variables correctly? For example, I have casesSold in the Main method, then I also have casesSold in the BarsSold and GovFees method. Is this
bad practice?
2.) How do I go about taking the information I have gathered from the user input and obtain the amount of netsales?
using System;
namespace Derp
{
class MainClass
{
static void Main ()
{
int casesSold;
Console.WriteLine ("Enter in the amount of cases sold: ");
casesSold = int.Parse (Console.ReadLine ());
Console.WriteLine ("The amount of bars sold were: " + BarsSold(casesSold));
Console.WriteLine ("The amount of cases sold were: " + casesSold);
Console.WriteLine ("Student Government Fees were: {0:C} ", GovFees(casesSold));
}
public static int BarsSold(int casesSold)
{
int BARS_PER_CASE = 12;
return casesSold * BARS_PER_CASE;
}
public static double GovFees(int casesSold)
{
const double PRICE_PER_CASE = 5.00;
const double STU_GOV_FEES = .10;
return STU_GOV_FEES * (PRICE_PER_CASE * casesSold);
}
}
}

New Topic/Question
Reply



MultiQuote






|