Scala First Look course at LinkedIn Learning
Translate the Java class below to Scala.
public class Calculator {
public static void main(String[] args) {
int x = 10;
int y = 5;
System.out.println(addition(x, y));
System.out.println(quotient(x, y));
System.out.println(times(x, y));
System.out.println(minus(x, y));
}
public static int addition(int a, int b) {
return a + b;
}
public static int quotient(int a, int b) {
if(b == 0)
return 0;
return a/b;
}
public static int times(int c, int d) {
return c * d;
}
public static int minus(int a, int b) {
return a - b;
}
}
Take the following list of numeric grades and print a letter grade for each value. Print also the average of all numeric grades.
var grades = List(100, 99, 75, 67, 89, 85, 92, 93, 60, 97, 88)
Result | Grade |
---|---|
93-100 | A |
86-92 | B |
77-85 | C |
69-76 | D |
Below 69 | F |
- Create a map with movies and their rating.
- Print the map.
- Add another movie to the map.
- Print the map again.
- Create an employee case class. Employees should have an id, first name and last name
- Override the toString method
- Create and print a list of employees
Employees should be printed in the following format
Employee ID: 12345
Full Name: firstName lastName