Hi just wondering if anyone could help me with this little problem:
import javax.swing.JOptionPane;
class Exam{
String name;
String location;
int day;
int month;
int year;
public Exam(String n, String loc, int d, int m, int y){
name = n;
location = loc;
day = d;
month = m;
year = y;
}
public String toString(){
return name+": "+location+" "+day+"/"+month+"/"+year;
}
public boolean compareTo(Exam other){
if (year < other.year) {return true;}
if (year > other.year) {return false;}
if (month < other.month) {return true;}
if (month > other.month) {return false;}
if (day < other.day) {return true;}
if (day >= other.day) {return false;}
}
}
public class examA
{
public static void main(String[] args)
{
Exam[] examArray = new Exam[5];
for(int i = 0; i < examArray.length; i++){
String name = JOptionPane.showInputDialog(null,"enter name");
String loc = JOptionPane.showInputDialog(null,"enter location");
int day = Integer.parseInt(JOptionPane.showInputDialog(null,"enter day"));
int month = Integer.parseInt(JOptionPane.showInputDialog(null,"enter month"));
int year = Integer.parseInt(JOptionPane.showInputDialog(null,"enter month"));
examArray[i] = new Exam(name,loc, day, month,year);
}
int lowest_loc = 0;
for(int m = 1; m < examArray.length; m++){
for(int i = 1; i < examArray.length; i++){
if(examArray[i] != null){
if (examArray[i].compareTo(examArray[lowest_loc])) {
lowest_loc = i;
}
}
}
JOptionPane.showMessageDialog(null,examArray[lowest_loc]);
}
System.exit(0);
}
}
examA.java:29: missing return statement
}
^
1 error
Doing this for revision as I have an exam tomorrow!!!