Newbie to Java coding

sMiLeYz

Platinum Member
Feb 3, 2003
2,696
0
76
I'm taking an introduction class to java and I'm having issues with an assignment. I can honestly say that I'm not very good at coding, can anyone spare some time to help a noob?
It's really introduction stuff but I can't wrap my head around some concepts.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Go ahead and post your question. The members don't mind helping with homework, as long as they know it's homework and aren't just being asked for answers. Asking for help with fundamental concepts is not a problem.
 

sMiLeYz

Platinum Member
Feb 3, 2003
2,696
0
76
My assignment so far:

"1. Prompt the user to enter a username and password. If either is incorrect, exit the program.
Otherwise, continue to process the program."

2. Read a file, and print information about the student ID."

I've written code that compiles and runs each process separately the separately but when I tried to put it together I can't.

I could actually use alittle one-on-one on this assignment. If possible :)
 

Ken g6

Programming Moderator, Elite Member
Moderator
Dec 11, 1999
16,836
4,816
75
Can you:
  1. take the code from inside the main method of each original program
  2. stick each in a separate method in a new program, and
  3. have the new program's main call each of the other two methods?
 

Dekasa

Senior member
Mar 25, 2010
226
0
0
Yeah. If you have two programs, and in the Main method of each you do what you need, all you have to do is something like this:

You have: Main1 & Main2. Main1 Prompts for username & password. Main2 reads from file & prints the student ID.

Since both of these are methods on their own, just make them a method in a third file, then call them both.

Main3 is your final file, which actually puts them together.

Main3 ()
{
User&Pass function() aka Main1;

ReadFromFile function() aka Main2;
}

in the same file, copy Main1 & Main2, rename them whatever(then call 'whatever')

Now that I re-read, this is exactly what Ken g6 said, just more visual.

Hope it helps, and feel free to ask if you don't understand.