Java Lab
Java Lab
grade
import java.util.InputMismatchException;
super(message);
int totalMarks = 0;
try {
marks[i] = mark;
totalMarks += mark;
// Calculate average
// Display average
} catch (InputMismatchException e) {
} catch (ArrayIndexOutOfBoundsException e) {
} catch (NotValidEvaluationException e) {
return "Distinction";
return "Fail";
2.
import java.util.*;
class Tourist {
this.name = name;
this.state = state;
this.famousSpot = famousSpot;
return state;
return famousSpot;
return "Tourist Spot: " + name + ", State: " + state + ", Famous Spot: " + famousSpot;
}
Collections.sort(touristList, Comparator.comparing(Tourist::getState));
System.out.println(tourist);
if (tourist.getFamousSpot().equals(searchSpot)) {
System.out.println(tourist);
found = true;
break;
}
}
if (!found) {