Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Homework 4 (17 pts) For this activity, you will create a . Rid file and a corresponding HTML file that will both be uploaded to

image text in transcribed
Homework 4 (17 pts) For this activity, you will create a . Rid file and a corresponding HTML file that will both be uploaded to wolfware. See the R file submission guidelines for all requirements - substantial credit may be taken off if the guidelines are not followed. The purpose of this activity is to practice writing functions, using for loops, and using vectorized functions. Loops/Function 1) (3 pts) Create a for loop to find the value of 10 factorial (10! = 10*9*8*...*1). . Initialize an object to store the value in (a vector of length 1 set to I will work). . Iterate from 1 to 10, multiplying and overwriting the value at each iteration of the loop 2) (6 pts) Now write a function that finds the factorial of a given number (so only one input, the number to find the factorial of). . Set the default value to find to 10 . Put in an if statement to check if the value of interest is greater than 100. If it is, stop the function and return a message saying the value is too large. If it isn't, compute the factorial. More Function Writing 3. (3 pts) Create a function called convert_cm_to_in that converts centimeters to inches. Use your function to determine how many inches a 25cm object is. Next, evaluate your function at a vector of integers from 0 to 100 (1 meter). 4. (1 pt) Add an addition input to the function that rounds the result to two decimal places by default. Rerun your function on the vector from 0 to 100. 5. (4 pts) Create a function called count_my_change that adds up the total amount of money you input. Include 5 arguments - dollars, quarters, dimes, nickels, and pennies Set the default value of ALL the arguments to 0 . Calculate a total value by multiplying each argument by its dollar value (i.e. 0.25 quarters, 0.01 pennies, etc.) Create a string that says "Your total is $amount" with the total, and put it inside a return statement to send it back to the user. Try out the function with no inputs. Then try it with 5 dollars, 2 dimes, 3 quarters, 4 pennies, and 1 nickel. End of Activity Go back through and check that you have completed all questions. Upload both the . Rid and the outputted pdf file to moodle

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability and Random Processes With Applications to Signal Processing and Communications

Authors: Scott Miller, Donald Childers

2nd edition

123869811, 978-0121726515, 121726517, 978-0130200716, 978-0123869814

More Books

Students also viewed these Mathematics questions