Starting from:
$30

$24

Homework 4: More Selection Statements

The goal of this assignment is to practice writing selection statements. You will also be asked to practice writing testing functions. You should work individually on this assignment.




Getting Started



You should start by creating a folder specically for this assignment. Create a README.txt le including three things: your name, the course name, and the name of this assignment. You should also use it answer any questions that may be asked in this assignment along with including any comments that you want the grader to consider when grading your assignment. You should not




include any code in your README.txt le.




More Selection Statements



Following the same process as we did in previous assignments, you will design, implement, and test the following functions. You should start by downloading the provided 2019spring-cs5001-homework04-StarterFiles.zip archive provided on Bottlenose and extract the moreSelection.py and moreSelectionTest.py les into the folder that you created specically for this assignment. You should modifying these les.




2.1 Function: largest




Design, implement, and test a function called largest that takes exactly 5 numbers and returns the largest of them.




2.2 Function: changeMaker




It is often the case that point of sales systems need to calculate how much change that a sales associate must give to a customer who has spent money in their store. For this problem, you are asked to design, implement, and test a function called changeMaker that calculates the precise way to make change for a sales associate. Your function should take the sales amount as well as the amount paid by the customer as input. The output should be a string that contains the exact change that the sales associate should give to the customer so that it can be printed to the sales terminal screen. You only need to consider twenties, tens, ves, ones, quarters, dimes, nickels, and cents. Be sure to use the fewest number of bills and coins possible.




For example, a customer spend $13.57 and pays with $100.00. The change would be:




Change: $86.43




twenties



1 five




1 one




1 quarter




1 dime

CS 5001 S19 Homework 04 { Page 2




nickel



3 pennies




Your solution string should match this output exactly and should use proper grammar (1 is singular, while more than 1 is plural). Do not include denominations that 0.




Hint: You will need to make use of the % operator to solve this problem. Be sure to thoroughly test your solution.




2.3 Function: multiply




Implement the following mathematical expression in a recursive function:






80


if y µ 0


<










f (x; y) =

x


if
y
== 1










x
+ f (x; y 1)
otherwise


:










Submit Files to Bottlenose



Before submitting, be sure that you have added a comment at the top of your source les that includes your name and the current date. Then create an archive of the folder that you created for this assignment containing all of the les that you have created and upload this archive to Bottlenose for grading. When you upload, be sure to check whether there are any auto-graders that evaluated your code and x any issues pointed out by the auto-graders. Homework 4 Review will be available immediate after the deadline for this assignment has passed. You will not be able to resubmit after completing the review .

More products