#include <stdio.h>
//************************************************************************
// Function: euroJarValue
//
//Purpose:
// Computes the total amount of money (in euros) inside a jar
// that contains several euro coins.
//
// Parameters:
// twoEuroCoins - number of 2-euro coins
// oneEuroCoins - number of 1-euro coins
// fiftyCentCoins - number of 50-cent coins
// twentyCentCoins - number of 20-cent coins
// tenCentCoins - number of 10-cent coins
// fiveCentCoins - number of 5-cent coins
// twoCentCoins - number of 2-cent coins
// oneCentCoins - number of 1-cent coins
//
// Returns:
// The total monetary value of the coins, as a double.
//***********************************************************************
double euroJarValue(int oneCentCount,
int twoCentCount,
int fiveCentCount,
int tenCentCount,
int twentyCentCount,
int fiftyCentCount,
int oneEuroCount,
int twoEuroCount)
{
// Declare local variable to hold total value
double totalValue = 0.0;
// Add value of 1 cent coins
totalValue = totalValue + (oneCentCount * 0.01);
// Add value of 2 cent coins
totalValue = totalValue + (twoCentCount * 0.02);
// Add value of 5 cent coins
totalValue = totalValue + (fiveCentCount * 0.05);
// Add value of 10 cent coins
totalValue = totalValue + (tenCentCount * 0.10);
// Add value of 20 cent coins
totalValue = totalValue + (twentyCentCount * 0.20);
// Add value of 50 cent coins
totalValue = totalValue + (fiftyCentCount * 0.50);
// Add value of 1 euro coins
totalValue = totalValue + (oneEuroCount * 1.00);
// Add value of 2 euro coins
totalValue = totalValue + (twoEuroCount * 2.00);
// Return the final computed total
return totalValue;
}
//*****************
int main(void) {
// Declare variables for coin counts
int oneCentCount = 2;
int twoCentCount = 0;
int fiveCentCount = 0;
int tenCentCount = 15;
int twentyCentCount = 5;
int fiftyCentCount = 2;
int oneEuroCount = 2;
int twoEuroCount = 5;
// Call the function and store result
double totalEuros = euroJarValue(oneCentCount,
twoCentCount,
fiveCentCount,
tenCentCount,
twentyCentCount,
fiftyCentCount,
oneEuroCount,
twoEuroCount);
// Print result
printf("Total: %.2f Euros\n", totalEuros
);
return 0; // indicate successful program end
}