Quote:
To pass this exercise you must demonstrate that you are able to
Write a program using WHILE loop constructs.
Write a program that is well indented.
Write a program that contains helpful comments.
Write a program that uses variable names that give an indication of their use.
Earliest Dates Write a program that repeatedly asks for the user to type in the name of a current film and then asks for its release date. It should stop when the special code QUIT is entered, and name the film that was released first. If several films were released in the earliest year the program should return the name of the last film entered.
Name a film? INCEPTION
What year was INCEPTION released? 2010
Name a film? TANGLED
What year was TANGLED made? 2011
Name a film? DIRTY DANCING
What year was DIRTY DANCING made? 1987
Name a film? PHILADELPHIA
What year was PHILADELPHIA made? 1993
Name a film? QUIT
The earliest film was Dirty Dancing released in 1987
This is the code that Iv written so far. I have no idea how to do beyond this.
Quote:
mport javax.swing.*; // import the swing library for I/O
class films
{
public static void main (String[] param)
{
movies();
System.exit(0);
} // END main
public static void movies()
{
String again = "";
String film;
int currentyear=2011;
String year = "";
String textinput1;
int oldest year=9999;
String textinput3;
while (!(again.equals("QUIT")))
{
film = JOptionPane.showInputDialog("Name a film");
textinput1 = JOptionPane.showInputDialog
("What year was" +film+ "released");
year = Integer.parseInt(textinput1);
again = JOptionPane.showInputDialog("Name a film");
}
System.out.println("The earliest film was");
if (current year < year){ // i cant seem to sort out the rest of the if statement
return;
} // END
} // END class