Problem 1: Creating and saving R files

Create and save the file p1.R on your computer. All your work should be in p1.R. You must work with one partner. You should work collaboratively. Both partners are responsible for being able to explain the work that’s been done to the preceptor.

Problem 2: Variables and Conditionals

Problem 2(a)

Write code to store the value 98 in a variable named my.score. Then, write code to output the value of my.score to the console.

Problem 2(b)

Suppose we’d like to adjust the score by multiplying it by 1.2, but making it so that the adjusted score is never above 100. So if my.score is e.g., 60, the adjusted score would be 60*1.2=72, but if my.score is 90, the adjusted score would be 100, since \(108=1.2\times 90\) is over 100. Write code to compute the adjusted score and store it in a variable named adj.score.

Problem 3: Function and using functions

Write a function named compute.adj.score which computes the adjusted score, as in 2(b). Write code that uses this function to display the results of adjusting the scores 60, 70, 80, 90, and 100

Problem 4: Functions and Conditionals

Problem 4(a)

Write a function named disc which computes \(b^2 - 4ac\) for the inputs a, b, and c. The first line of your solution code should look like

disc <- function(a, b, c){

Now use this function to compute the discriminant of two quadratic equations.

Problem 4(b)

Write a function named num.solns which returns the number of unique real solutions of the quadratic equation \(ax^2 + bx + c\).

Problem 4(c)

Write a function qaud.roots which prints the solutions (if any) of a quadratic equation.