Practical 9
Practical 9
All files must include your name and student number at the very top of every file
(The ve concept). Marks will be subtracted for every missing occurrence.
Your program must run.
Code that is commented out is not marked.
You must use comments to separate your program login. In other words, use
comments to mark the different sections of your code.
Read through the whole document before starting to get an overview of the practical
- Create a method named DisplayUnits that does not return anything and accepts a
string prompt, the cents to convert, and a unit value as a whole number.
o Unit values refer to the money units that the amount entered can broken down
into.
1
The formal cents paramter and actual cents parameter must refer to the same memory
location. This method should determine how many units the cents can convert to, display
the result (See Figure 3), and get the remaining cents to use in the next unit conversions.
- Create a method called isAnotherOne that returns a bool. This method should prompt
the user for another conversion (See Figure 4) and return the bool result of the user’s
response.
Main() method:
- Use an appropriate loop to run the program at least once before prompting the user for
another conversion.
o The loop should be controlled by the state of one of your custom methods (See
Figure 5 and Figure 6).
- Call the GetDecimal method (Hint: remember it returns a bool) to prompt the user for
an amount and check that the user input is valid.
o If the user’s input is not valid, display a message as in Figure 6 and allow the
user start again. You may not repeat code to allow the user to start again. Call
an existing method instead.
o If the user’s input is valid, convert the amount entered by the user to cents and
call the DisplayUnits method for each unit value and provide prompts for each
unit value as in Figure 3.
2
Figure 4: User is prompted to complete another
conversion.
3
Figure 7: User error detected – message is
displayed and user is prompted to enter
amount again.
Submission checklist
I have added a comment block with my information before the using directives.
I have used comments to separate my program logic.
I have zipped my entire solution folder and named it correctly: Surname (Student
number) where Surname and Student number is replaced with my own surname and
student number.
I have downloaded my zipped folder to check that I have submitted the correct project
folder (You must submit the entire project folder, not just the .sln file).