Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   While Loops - Error Help pls (http://www.go4expert.com/forums/loops-error-help-pls-t27118/)

Zombie_GurL 9Nov2011 07:04

While Loops - Error Help pls
 
Hi,
I have been asked to write a program for one of my 1st year modules. im new to programming. Given below is the question. I have answered it partly and there are some errors and its incomplete too. it would be really great if someone could help me to complete it.

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.

Code:

import 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

Thanks in advance
ZombieGurL


All times are GMT +5.5. The time now is 09:11.