🔒 Closed Patulong po sa error please

Status
Not open for further replies.
1651471969003.webp

1651471983561.webp

sino po may idiea yan na lang po kasi error sakin

eto po yung full code... online compiler lang po pinapagamit samin
import java.util.*;
import java.nio.file.*;
import java.io.*;
import static java.nio.file.StandardOpenOption.*;

public class TaskPerf6 {

Scanner sc = new Scanner(System.in);
String filePath = "C:\\MERCADO\\Desktop\\records.txt";
public TaskPerf6(){
try {
System.out.println("Press R to Register for account");
System.out.println("Press L to Log in your account");
System.out.println("\nEnter a letter: ");
String UserInput = sc.nextLine();

if (UserInput.equals("R")){
registerAccount();
}else if(UserInput.equals("L")){
accountLogin();
}
}catch (Exception e) {
}
}



void accountLogin(){
try {
Path p1 = Paths.get(filePath.toString());

InputStream IS1 = Files.newInputStream(p1);
BufferedReader readerR = new BufferedReader(new InputStreamReader(IS1));
System.out.println("\nLog in to your account\n");
System.out.println("Enter your Username: ");
String username = sc.nextLine();
System.out.println("Enter your Password: ");
String password = sc.nextLine();
String n1 = "";
String accnt;
String pass;

boolean isAlphanumeric = false;
while ((n1 = readerR.readLine()) != null) {
String[] records =n1.split(",");
accnt = records[0];
pass = records[1];
if (accnt.equals(username) && pass.equals(password)){
isAlphanumeric = true;
}
}



if(isAlphanumeric == true){
System.out.println("Successfully Logged in!");
}else {
System.out.println("Incorrect username or password, please try again.");
}

}catch (Exception e){
System.out.println(e.getMessage());
}
}

void registrationAccount(){
try{
Path npath = Paths.get(filePath.toString());
OutputStream output = new BufferedOutputStream (Files.newOutputStream(npath, CREATE));
BufferedWriter wrtr = new BufferedWriter (new OutputStreamWriter(output));
System.out.println("\n Register an account please. \n");
System.out.println("Enter preffered Username: ");
String userName = sc.nextLine();
System.out.println("Enter preffered Password: ");
String passWord = sc.nextLine();

wrtr.write(userName + "," + passWord);
wrtr.newLine();
System.out.println("\nYour account has been Registered successfully!");
wrtr.close();
output.close();

new TaskPerf6();
}catch(Exception e){
System.out.println(e.getMessage());

}
}

public static void main (String[] args){
new TaskPerf6();
}
}
 
yung name ng void na declared mo is
"registrationAccount"
ang ginamit mo is "registerAccount();"

imbis na
if (UserInput.equals("R")){
registerAccount();

gawin mong
if (UserInput.equals("R")){
registrationAccount();
 
yung name ng void na declared mo is
"registrationAccount"
ang ginamit mo is "registerAccount();"

imbis na
if (UserInput.equals("R")){
registerAccount();

gawin mong
if (UserInput.equals("R")){
registrationAccount();
papi pakisss mahal na kita
salamat!!
 
Status
Not open for further replies.

About this Thread

  • 4
    Replies
  • 1K
    Views
  • 2
    Participants
Last reply from:
JakeMosby

Online now

Members online
1,018
Guests online
958
Total visitors
1,976

Forum statistics

Threads
2,276,215
Posts
28,968,392
Members
1,231,170
Latest member
nico062026
Back
Top