Description
Exercise 1: Final Grade
• In each class you take at a university, you typically obtain a
number of different marks (for assignments, midterms,
quizzes, finals …) each out of different maximum value.
Instead of compu/ng your final/current grade on paper, write
a program that does that for you.
In par/cular, write a java program that computes and displays
the final grade of a student. In the main, the user should be
prompted to provide the total number of marks, and enter
each mark, one by one, together with “out of” value for that
mark.
Your program should have a method called “normalized_grades”
that takes as an input references to two arrays, one with
marks and the other with “out_of” values, and returns a
reference to an array with grades our of 100.
•
Exercise 2: Range of thrown ball
• Write a program that will calculate how far a ball thrown at v
metres per second will travel horizontally in metres,
depending on the angle θ (in degrees) at which it is thrown.
• Return an array of values where:
Range[0]: ball is thrown at 0 degrees above horizontal
Range[1]: ball is thrown at 10 degrees above horizontal
…
Range[9]: ball is thrown at 90 degrees above horizontal
(that is, straight up).
Example: Range of thrown ball
range
θ
0 m
Example: Range of thrown ball
• Formula:
θr = angle in radians
• Where:
g = 9.8, constant acceleration due to gravity.
θ π θ
180 r
=
g
v
range
θ r θ r 2 cos sin 2
=
Example: Range of thrown ball
• Develop your algorithm and then implement
it in Java.
• Useful items:
– Math.PI: value of π.
– Math.sin(x): sine of x, where x is in radians
– Math.cos(x): cosine of x, where x is in radians