any ideas on what i screwed up here????

Status
Not open for further replies.

mrdinkel

Daemon Poster
Messages
584
I was just thinking about a thus password generator program i was writing, based on a principle they teach in java.

---------------------------------------------------------------------------------------
import javax.swing.*;

class josh{
public static void main (String [] args )
{
JFrame Input;
Input = new JFrame ();
String name, dob,first, middle, last, month, date, year,slash, fi, mi,li,password, space;
slash = "/";
space = " ";

name = JOptionPane.showInputDialog(null, "Enter your full name (first, middle, last:");
dob = JOptionPane.showInputDialog(null, "Enter your birth date(MM/DD/YYYY");

//Extract first, middle, last name

first = name.substring(0,name.indexOf(space));
name = name.substring(name.indexOf(space)+1, name.length( ));

middle = name.substring(0,name.indexOf(space));
last = name.substring(name.indexOf(space)+1, name.length( ));

//extract month, day and year

month = dob.substring(0,name.indexOf(slash));
dob = dob.substring(name.indexOf(slash)+1, name.length( ));
date = dob.substring(0,name.indexOf(slash));
dob = dob.substring(name.indexOf(slash)+1, name.length( ));
year = dob.substring(0,name.indexOf(slash));

//compute password
fi = first.substring(0,1);
mi = middle.substring(0,1);
li = last.substring(0,1);
password = month + fi + date + mi + year + li;
//output the result
JOptionPane.showMessageDialog(null, "Your password is " + password );


}
}

--------------------------------------------------------------------------------------

Anyone see a probem that I obviously am missing?
 
tell us what you want your script to do? (exactly, step by step) and use code tag to enclose your code, to preserve indenting..
 
In essence, I want it to bring in the Full Name, and then birthdate....

mport javax.swing.*;

class josh{
public static void main (String [] args )
{
Frame Input;
Input = new JFrame ();

String name, dob,first, middle, last, month, date,
year,slash, fi, mi,li,password, space;

slash = "/";

space = " ";


name = JOptionPane.showInputDialog(null, "Enter
your full name (first, middle, last:");

dob = JOptionPane.showInputDialog(null, "Enter your birth date(MM/DD/YYYY");

I know this all works, because it pulls up an input window...

Then. it uses the next bit of information to seperate it into the three parts of the name (First, Middle Initial, Last), which is bisected ever time there is an instance of " " ;

first = name.substring(0,name.indexOf(space));
name = name.substring(name.indexOf(space)+1, name.length( ));

middle = name.substring(0,name.indexOf(space));
last = name.substring(name.indexOf(space)+1, name.length( ));

This next batch allows it to break the date apart into smaller bits, and breaks it apart when it finds the "/

month = dob.substring(0,name.indexOf(slash));
dob = dob.substring(name.indexOf(slash)+1, name.length( ));
date = dob.substring(0,name.indexOf(slash));
dob = dob.substring(name.indexOf(slash)+1, name.length( ));
year = dob.substring(0,name.indexOf(slash));

Lastly, it is supposed to reassambl t all, put it in a string called password and then print it in a dialog box, saying "Your Password is : 10J13L85D".

It stops outputting when you get to the input of date... then it just terminates....

Maybe one day I will understand the premise of programming.
 
Status
Not open for further replies.
Back
Top Bottom