Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
WS #2 Answers (2016):
1.) Parameter Mystery1 Output:
int a = 4, b = 7, c = -2; -4 + 12 = 11
mystery(a, b, c); 2 + 8 = 1
mystery(c, 3, a); 0 + 10 = 5
mystery(a + b, b + c, c + a);
//formal parameters in method header:
public static void mystery(int c, int a, int b)
2.) Parameter Mystery2 Output:
String a = “king”; a two and a queen beats a king
String b = “two”; a queen and a queen beats a b
String c = “queen”; a two and a king beats a five
String two = “five”; a king and a two beats a queen
a queen and a two beats a five
sentence (a, b, c);
sentence(“b”, c, c);
sentence(two, “two”, a);
sentence(c, a, b);
sentence(two, “queen”, b);
public static double distanceFormula(int x1, int y1, int x2, int y2)
{
double dist = Math.sqrt((Math.pow((x2 - x1), 2)) +
(Math.pow((y2 - y1), 2)));
return dist;
}