Java = 75% of the grade (50/50 exam and assignment, but both must have a passing grade), Rstudio = 25% of the grade.
The exam is 3 hours and consists of two parts of 1,5 hours of each programming language. For Java, you can use all your own files, the internet... except for communication media. For R, you have access to all the course files on Toledo (chapters, exercisesolutions... ), but you can only bring printed notes (not your own scripts!!!!).
Tip: Make for both parts the trial/old exams on Toledo.
17/01/2023
Java:
You are hired by a university to make a program that can hold different types of courses. Specific types are:
Bachelor courses: name of the course, level (bachelor/master...), credits, List of assignments.
Master courses: name of the course, level (bachelor/master...), credits, List of assignments, List of weights per assignment.
Course objects can also be created when no list of assignments is entered in the constructor method. All objects and future course types must have the methods below:
public void printAssignments();
public double calculateGrade(ArayList<Integer> score);
The first method just prints out what courses are present in the List of assignments. The second method differs per type of course. Bachelor courses take the average of all the points in the score ArrayList. Master courses multiply the score per course with the weights present in the list of weights. Then the weighted average is taken.
Make sure the program prints out statements that are useful for the user. The calculateGrade method can likely create invalid output/make errors. Make sure the program throws nescesary exceptions. The calculateGrade returns the value NaN when an invalid output is created.
R:
Q1)
Read in the excel animals. Use the replace method to replace the values -999 with NA in two columns (Max_age and gestation). This becomes 'animals2'.
Q2)
Perform a linear regression on animals2 following the equation: (expl) = alfa + beta * (var). With expl being gestation and var being Max_age. Save the intercept and slope variables in a vector "original".
Q3)
Take a subset 'sub1' from animals of 30 random rows with the function sample_n. Perform another linear regression as above on sub1.
Save the two coefficients in a new data frame with the column names being 'a' for the first variable and 'b' for the second variable. The row name should just be the number of the row. This data frame is called 'regres_coeff'.
Q4)
Repeat question 3 50 times and store all the values in the new data frame regres_coeff. The result holds 50 rows in total.
Q5)
Make a histogram plot with ggplot2. The plot shows the distribution of 'a' in regres_coeff on the left and the distribution of 'b' in regres_coeff on the right. (this is all in the same plot). Add a red vertical line indicating the values of 'a' and 'b' in both corresponding plots.
Q6)
make a function that combines all previous steps from questions 4 and 5. The function is called 'regres.f' and has two input variables 'n' and 'it'. 'n' is the size of sample_n, 'it' is the number of iterations in the for loop. Make a plot with this function for regres.f(40,500).
Q7) Make a plot in the following 3 steps. All information is present in the same window.
Make a blue scatterplot of animals2 variables Max_age and gestation. The background must be black and white.
Add a linear regression line of "animals.lm" coefficients. The line is red and does not show a confidence interval.
Add all 50 regression lines in regres_coeff in a for loop.
18/01/2022
Files regarding this exam can be found in dropbox.