As the new programming wizard at Hogwarts School of Wizardry, you are being given a series of tasks to make the magical world run more smoothly. Your first task is to assist Gringott's Bank in the conversion of currency from Magical Money (Galleons, Sickles, and Knuts) to Muggle Money (Euros). You have been asked to create a program which prompts the user for an amount of money in Galleons, Sickles, and Knuts, converts it to Euros, and also computes the commission that Gringotts charges. Information on conversion rates and commissions are given below.
In this section, for most homeworks, we'll provide a list some of the relevant concepts. Don't forget, however, that CS is a lot like math in that you can never afford to forget concepts you learned earlier in the course; every new homework and programming concept builds on previously learned ones. In addition, later in the quarter, determining which concepts you should apply might well be part of your homework.
In this homework, keep an eye out for...
#define
)
Your program should prompt the user to enter (in order) the number Galleons, Sickles, and Knuts to exchange into Euros. The program should then convert to Euros and calculate the commission to charge. The program should print the value in Euros, the commission in Euros, and the amount to be paid to the customer.
There are 17 Sickles in a Galleon, and 29 Knuts in a Sickle. You may use the conversion rate that one Galleon is worth 60.0 Euros. The commission charged by Gringott's is 5.0 %.
You should read in the Galleons, Sickles, and Knuts as ints. Use doubles to represent the amount in Euros and the commission. The sample executable uses the formatting code %.2lf to display a double to two decimal digits.
Your program should run like the sample executable we have provided on the web. The computed numbers should be very close. (Note - the computation can be done in several different ways - because of rounding, the answers may differ in the last displayed digit.) The spacing in the output doesn't have to be identical, but the order of the inputs and outputs must match exactly. (When we can, we use automated scripts to test submitted programs, which is one reason that it is important that your program accepts input and produces output in the same order as the sample program. The other reason consistency is important is TA sanity when they grade dozens of programs.)
Your program should prompt the user for inputs and give descriptive messages of the output, but does not need to match all of the verbiage of the sample solution.
It is important that your program be well-written, as well as work correctly. Besides general guidelines like picking good variable names, there a few specific things that are required for this assignment.
#define
to give meaningful names to significant
constants. In particular, the relationships between
Galleons, Sickles, and Knuts, the conversion factor, and the
commission rate
should be given names using #define
, not written
directly into expressions in your program.if
,
while
, for
, etc.) in this assignment. The
program can be written using only input and output plus assignment
statements. int
and double
(floating-point)
variables appropriately in your program.The due date for this assignment is at the top of this page. Be especially aware of the web submission deadline, as submission times are tracked precisely and we cannot accept late submissions.
If any clarifications or changes need to be made for this homework, they will be posted to the cse142-announce email list and linked here.