Exercise 1
-----------

superUser
1234
superUser
5678
The old password of superUser was 1234
superUser
9000
superUser
5678

* Each correct answer is worth 1pts


Exercise 2
-----------

correct return type  (void)                               [2pts]
correct initialization  for max   (max = arr[0])                [2pts]
correct branch condition for "if" statement (max < arr[i])[2pts]
correct bound check in for loop (i<arr.length)            [2pts]
correct use of avg in println statement  (avg)            [2pts]


Correct program:

	public static void averageAndMax(int[] arr){
		double avg = 0;
		int max = arr[0];
		double sum = 0;
		for (int i=0; i<arr.length; i++){
			sum +=arr[i];
			if (max < arr[i]){
				max = arr[i];
			}
		}
		avg = sum/arr.length;
		println("The average is "+ avg);
		println("The maximum is "+ max);
	}


Exercise 3
----------

Lines that will cause compilation errors: 11 and 12  [2pts]
Reason: you can not assign an object of a superclass to a variable
         of the type of the subclass.  

The following result will be printed to the console:

Hej from class A       [2pts]
Hello from class B     [2pts] 
Hej from class A       [2pts]
Hej from class A       [2pts]


Exercise 4
----------

Block B: [1pts]

	private String country;
	private int athletes;


Block C: [2pts]

	this.sportName = "Aquatics";
	this.country = "Sweden";
	this.athletes = 11;

Block D: [1pts]

	this.sportName = sportName;
	this.country = country;
	this.athletes = athletes;

Block E: [3pts]

	this(sport.sportName,sport.country,sport.athletes);

Block F: [1pts]

	return this.sportName;

Block G: [4pts]

	if(this.sportName.equals(s.sportName) && !this.country.equals(s.country) &&
			this.athletes>0 && s.athletes >0){
		return true;
	}
	else {
		return false;
	}

Block H: [3pts]

	return this.country + " has " + this.athletes + " athletes in " + this.sportName; 

Block I: [2pts]

	private Sport sport;
	private String eventName;
	private int placement;
	private String athleteName;

Block J: [3pts]

	super();
	this.sport = new Sport();
	this.eventName = "Women's 100m butterfly";
	this.placement = 1;
	this.athleteName = "Sarah Sjöström";		

Block K: [3pts]

	super(sport);
	this.sport = sport;
	this.eventName = eventName;
	this.placement = placement;
	this.athleteName = athleteName;

Block L: [3pts]

	return this.athleteName + " was ranked " + placement + " in " +
			eventName + " in " + this.getSportName(); 	

Block M: [4pts]

	if(this.placement > e.placement)
		return this.athleteName + " performed better than " + e.athleteName;
	else if(this.placement == e.placement)
		return this.athleteName + " performed the same as " + e.athleteName;
	else
		return e.athleteName + " performed better than " + this.athleteName;



Exercise 5
-----------

a) 10 pts

	public static String maxAthletesJudo(Sport[] s){
		String maxCountry="";
		int maxAthletes = 0;
		for(int i=1; i<s.length;i++){
			if(s[i].sportName.equals("Judo") && s[i].athletes > maxAthletes){
				maxAthletes = s[i].athletes;
				maxCountry = s[i].country; 
			}
		}
		if (maxAthletes == 0)
			return "No Judo athletes in this olympics";
		else
			return maxCountry + " has " + maxAthletes + "in Judo";
	}

b) 10 pts

	public static void firstThree(Event[] e){
		Event first=null, second=null, third=null;
		for(int i=0; i<e.length; i++){
			if(e[i].eventName.equals("Women's") && e[i].getSportName().equals("Golf")){
				if(e[i].placement == 1){
					first = e[i];
				}
				else if(e[i].placement == 2){
					second = e[i];	
				}
				else if(e[i].placement == 3){
					third = e[i];
				}
			}
		}
		println(first); 
		println(second); 
		println(third);
	} 



Exercise 6
-----------


public int[] fizzArray3(int start, int end) { // correct signature and return parameters [5pts]
 int len = end - start;
 int[] res = new int[len];      // correct array length [5pts]   
 for (int i=start; i<end;i++){  // correct loop bounds [5pts]
      res[i-start] = i;         // correct loop body [5pts]
 }
  return res;
}

