#include /* Currency conversion from Wizard Money to Muggle Money, For a description of the Wizard Econony, see Harry Potter and the Sorcerer's Stone by J. K. Rowling. The Galleon, Sickle, Knut conversion factors are from Chapter 5, Diagon Alley (page 75). The Muggle-Wizard exchange rate can be found in the Daily Prophet. This program recieves as input an amount in Wizard money, and displays the corresponding amount in Muggle Money and computes the commission for Gringotts. Programming Wizard: Richard Anderson Student ID #: 123456789 Date: Sept 27, 2000 */ /* Basic conversion factors */ #define EUROS_TO_GALLEON 60.0 #define KNUTS_PER_SICKLE 29 #define SICKLES_PER_GALLEON 17 /* Derived conversion factors that we need in the computation */ #define KNUTS_PER_GALLEON (KNUTS_PER_SICKLE * SICKLES_PER_GALLEON) #define EUROS_TO_KNUT (EUROS_TO_GALLEON / KNUTS_PER_GALLEON) #define COMMISSION 0.05 int main (void){ int galleons; /* Number of galleons input */ int sickles; /* Number of sickles input */ int knuts; /* Number of knuts input */ int total_sickles; /* Money converted to sickles */ int total_knuts; /* Money converted to knuts */ double euros; /* Exchange value in Euros */ double conversion_fee; /* Fee charge */ double net_euros; /* Money paid to customer */ char c; /* Print banner to user */ printf("Welcome to Gringott's currency exchange\n"); printf("It is our pleasure to exchange your wizard money "); printf("for Muggle Money\n"); printf("The current exchange rate is %.3lf Euros to the Galleon\n", EUROS_TO_GALLEON); printf("We charge a %.2lf %% commission\n", 100.0 * COMMISSION); printf("\n\n\n"); /* Get amount of money to exchange */ printf("Please enter the amount of Wizard money you wish to exchange\n"); printf("How many Galleons?\n"); scanf("%d", &galleons); printf("How many Sickles?\n"); scanf("%d", &sickles); printf("How many Knuts?\n"); scanf("%d", &knuts); /* Compute the amount in Euros */ /* We first convert everything to Knuts, and then */ /* convert the Knuts to Euros */ total_sickles = SICKLES_PER_GALLEON * galleons + sickles; total_knuts = KNUTS_PER_SICKLE * total_sickles + knuts; /* Now convert to Euros */ euros = total_knuts * EUROS_TO_KNUT; /* Finally subtact the commision, and display the result */ conversion_fee = euros * COMMISSION; net_euros = euros - conversion_fee; printf("For %d Galleons, %d Sickles, %d Knuts,\n", galleons, sickles, knuts); printf("Gringott's will give you %.2lf Euros, \n", euros); printf("less a fee of %.2lf for a total of %.2lf Euros\n", conversion_fee, net_euros); printf("\n\npress a key and hit 'Enter' to quit..."); scanf("%c%c",&c,&c); return 0; }