Write a program that computes the amount of money the computer club will receive from the proceeds of their granola project. Each case has 100 bars. The ranola bars sell for $1.50 per bar. Each case costs $100.00. They are required to give the student government association 10% of their earnings. Display their proceeds, showing the amount given to the student government association. Show all the values formatted with currency. Do a compile-time initialization using 29 for cases sold.
using System;
class Program
{
static void Main()
{
const int casesSold = 29; // Number of cases sold
const double barPrice = 1.50; // Price of each granola bar
const double caseCost = 100.00; // Cost of each case
const double sgaPercentage = 0.10; // Percentage of earnings to give to student government association
// Calculate the total earnings
double totalEarnings = casesSold * caseCost * barPrice;
// Calculate the amount to give to the student government association
double sgaAmount = totalEarnings * sgaPercentage;
// Calculate the proceeds after giving to SGA
double proceeds = totalEarnings - sgaAmount;
// Display the results
Console.WriteLine("Granola Project Proceeds");
Console.WriteLine("-----------------------");
Console.WriteLine("Cases Sold: {0}", casesSold);
Console.WriteLine("Earnings: {0:C}", totalEarnings); // Display earnings as currency
Console.WriteLine("SGA Amount: {0:C}", sgaAmount); // Display SGA amount as currency
Console.WriteLine("Proceeds: {0:C}", proceeds); // Display proceeds as currency
}
}
Executed Output:
Granola Project Proceeds
-----------------------
Cases Sold: 29
Earnings: $4,350.00
SGA Amount: $435.00
Proceeds: $3,915.00