0% found this document useful (0 votes)
6 views15 pages

Laboratory Exer - File Handling3

The document outlines a hands-on programming activity where students must create a program that handles user registration and login, including file handling for storing credentials. Students are instructed to work in pairs, with one researching code and the other coding, and must submit a joint project for evaluation. Key procedures include creating a project folder, implementing user input validation, and managing text file operations for storing and retrieving usernames and passwords.

Uploaded by

synxerious28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views15 pages

Laboratory Exer - File Handling3

The document outlines a hands-on programming activity where students must create a program that handles user registration and login, including file handling for storing credentials. Students are instructed to work in pairs, with one researching code and the other coding, and must submit a joint project for evaluation. Key procedures include creating a project folder, implementing user input validation, and managing text file operations for storing and retrieving usernames and passwords.

Uploaded by

synxerious28
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

HAND-ON

ACTIVITY
Computer Programming 2
Task Performance

User Log-in
Programming Activity
Objectives
Create a program that handles
exception and allows writing to and
reading from a text file.
Instruction
• Select a partner to be part of the activity.
• One of you will help research for code for trial and error
and one of you will do the main program.
• At the end of the class, both of you will pass the same
project.
• Each group will be evaluated with 10 is the highest score
base on how far is your development.
• Absent member will not have score during evaluation.
Sample Layout
PROCEDURE
1. Create a folder named
LastName_FirstName (ex. Reyes_Mark)
in your local drive D:
2. Create a new project named LastName1
LastName2 _FileHandling1X. Set the
project location to your own folder.
PROCEDURE
3. Write a program that will:
Ask the user to select between two (2) options:
• Register: User shall input his desired username and password.
These shall be saved in a text file named records.txt. Only
alphanumeric characters are allowed.

• Login: User is asked to input a username and password.


Validate using the text file created from the Register option. If
both the username and password are correct, display the
message “Successfully logged in”, else, display “Incorrect
username or password”.
TIPS
1. try use FileOutputStream in creating a file record.txt
2. If file exist, delete and create a new file again
3. To login, use InputStream to retrieve data from record.txt
4. Check if the record.txt data is match
5. Create a method that will validate the registration if contains
special character and whitespace
6. If contains, throw Exception
7. You can user JOptionPane.showMessageDialog to display pop-up
message
8. Use getText and getPassword method
record.txt

When register button is When login button is click, get


click, new file will be the data from the file and
created. match up the user input.
SAMPLE
Enter

Username: test
Password: test

Error dialog box will


pop-up if no
record.txt is not
found
Enter

Username: test
Password: test

After you hit


REGISTER, success
dialog box will appear
and record.txt will be
created
Enter

Username: test1
Password: test1

After you hit Login,


error dialog box will
appear means you
enter invalid username
or password
DATA FLOW : LOGIN
LOGIN

Display NO EXIST YES Read


error record.txt record.txt

Display YES NO
If credentials Display
Success match error
DATA FLOW : REGISTER
REGISTER

Overwrite YES EXIST NO Create


data record.txt record.txt

WRITE Data to
Record.txt

Display
Success

You might also like