All Assingnments are due at 11:55 pm. Grammars are available from the file COSC 105.pptx on Courses.
For grammar problems, find the left-most derivations. Email your solutions directly to Brad.Cupp@pepperdine.edu.
Submit your homework as a presentation on RPubs, one solution per slide. Make sure that the assignment number and your name are on the first slide. Send me an email with the URL for your RPubs root directory.
Martin Luther King, Jr. Day—Nothing due.
Submit solutions to each problem below as a separate slide in a single RPubs presentation.
meters(feet, inches) that takes feet and inches as input and returns the equivalent number of meters. For example, meters(4,8) should return 1.4224. One inch is exactly 0.0254 meters.celcius(fahrenheit) that takes degrees fahrenheit as input and returns the equivalent temperature in degrees celcius.fv(pv, years, rate) that computes the future value of present value pv for the given rate and years.Submit solutions to each problem below as a separate slide in a single RPubs presentation.
hyp(sideA, sideB) with two numeric parameters for the lengths of two perpendicular sides of
a right triangle that returns the length of the hypotenuse. duration(hours) that takes an integer input of hours and returns a vector containing the equivalent number of weeks, days, and hours (in that order). For example, duration(4123) should return (24,3,19) representing 24 weeks, 3 days, and 19 hours.abcd. EXTRA CREDIT CHALLENGEUse the range operator to answer problem 3.
Submit solutions to each problem below as a separate slide in a single RPubs presentation.
A salesperson's commission is computed as 15% of the sales that exceed $1000. For example, someone who sells $1,100 should receive a commission of $15. Someone who sells $500 should receive a commission of $0. Write the function commission(sales) that returns a commission amount based on a sales amount.
In a bowling tournament, participants bowl three games and receive a consolation prize of $15 regardless of their score. Those bowlers whose three-game average are at least 200 get an additional prize of $50. Write the function award(score1, score2, score3) that returns the award earned based on the three scores.
Submit solutions to each problem below as a separate slide in a single RPubs presentation.
The fine for speeding in a 45 MPH zone is $10 for every mile per hour over the speed
limit for speeds from 46 to 55 MPH. It is $15 for every additional mile per hour
between 56 and 65 MPH. It is $20 for every additional mile per hour over 65 MPH. For
example, the fine for driving 57 MPH is $100 for the first 10 MPH plus $30 for the 2
MPH in excess of 55 MPH, for a total of $130. Write function fine(speed) returns the fine earned for the numeric speed parameter. Use the smallest possible number of comparisons.
Write the function sort(a,b,c) that outputs a vector containing numeric parameters a, b, and c in descending
order. Your function must contain no local or global variables. It must use no more than five comparisons and
must work correctly even if some of the integers are equal. A comparison is any use of a relational operator. For example, x < 5 contains one comparison, while x < 5 && x > 2 contains two comparisons.
More to come…