Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » any ideas on what i screwed up here????
Closed Thread
Old 09-08-2005, 04:53 PM   #1 (permalink)
 
Ultra Techie

Join Date: Jan 2003

Posts: 584

mrdinkel

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

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?
__________________
A+ Core Hardware, Software Certified (May 13 2005)
the new beast...

AMD Athlon XP 3200+ Barton running at 2.16 Ghz.
GeForce MX 4000 (mainly takes the load off the main system)
Creative Labs Audigy 24-bit sound.
Some Case from tigerdirect
512 MB Ultra DDR RAM.
80GB Seagate HDD
LiteOn CD-RW / DVD ROM drive.
currently looking at a litescribe drive at staples, due to its ability to label the CD shortly after being burned.
mrdinkel is offline  
Old 09-10-2005, 10:52 PM   #2 (permalink)
 
Super Techie

Join Date: May 2005

Posts: 479

furtivefelon

Default

tell us what you want your script to do? (exactly, step by step) and use code tag to enclose your code, to preserve indenting..
__________________
lisp hacker
running: FreeBSD 5.4 - still learning
develop with: SBCL + emacs for lisp, Anjuta IDE +gcc for c, SPE for python..
browse with: opera
furtivefelon is offline  
Old 09-11-2005, 12:41 AM   #3 (permalink)
 
Monster Techie

Join Date: Jul 2003

Posts: 1,179

Emily is on a distinguished road

Send a message via AIM to Emily
Default

And also tell us what's going wrong, and where if you know.
__________________
<a href=\"http://www.upstark.com\">www.upstark.com</a>
Emily is offline  
Old 09-12-2005, 01:03 AM   #4 (permalink)
 
Ultra Techie

Join Date: Jan 2003

Posts: 584

mrdinkel

Default

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.
__________________
A+ Core Hardware, Software Certified (May 13 2005)
the new beast...

AMD Athlon XP 3200+ Barton running at 2.16 Ghz.
GeForce MX 4000 (mainly takes the load off the main system)
Creative Labs Audigy 24-bit sound.
Some Case from tigerdirect
512 MB Ultra DDR RAM.
80GB Seagate HDD
LiteOn CD-RW / DVD ROM drive.
currently looking at a litescribe drive at staples, due to its ability to label the CD shortly after being burned.
mrdinkel is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On