Ricardo Gallardo
New Member
- Joined
- Jun 19, 2011
- Messages
- 1
- Reaction score
- 0
- Points
- 1
import java.io.*;
import java.util.Scanner;
class test {
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
System.out.print("Enter your password: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String pass = null;
try {
pass = br.readLine();
} catch(IOException e) {
System.out.print("Error");
System.exit(1);
}
System.out.print("Retype password: ");
BufferedReader bro = new BufferedReader(new InputStreamReader(System.in));
String retype = null;
try {
retype = bro.readLine();
} catch(IOException e) {
System.out.print("Error");
System.exit(1);
} if(pass.equals(retype)) System.out.println("Succesful input"); else System.out.println("input incorrect");
int lenght = pass.length();
if(lenght > 10) System.out.println("Password too long");
if(lenght < 4) System.out.println("Password too short");
if(lenght <= 10 && lenght >= 4 && pass.equals(retype)) System.out.println("Password characters are within margins, succesful output");
if(lenght > 10 || lenght < 4 || (!(pass.equals(retype))))System.out.prinรขโฌยฆ or more errors have been spotted with your password, please be sure they are the same and are within margins");
if(pass.equals(retype) && lenght <= 10 && lenght >= 4){
System.out.print("Both password are correct, do you want to continue? Y/N ");
char yn;
yn = scan.findInLine(".").charAt(0);
if(yn == 'Y' || yn == 'y'){
System.out.println("You have choosen yes we are going to continue");
System.out.print("Please enter your nickname: ");
BufferedReader user = new BufferedReader(new InputStreamReader(System.in));
String nick = null;
try {
nick = user.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.print("Please enter your email: ");
BufferedReader mail = new BufferedReader(new InputStreamReader(System.in));
String email = null;
try {
email = mail.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.print("Please enter city where you live: ");
BufferedReader cit = new BufferedReader(new InputStreamReader(System.in));
String city = null;
try {
city = cit.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.print("Please enter your postal code: ");
String postal = null;
try {
postal = cit.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.println("Please verify if your data is correct:");
System.out.println("Password: " + pass);
System.out.println("Nickname: " + nick);
System.out.println("City: " + city);
System.out.println("Postal code: " + postal);
System.out.println("Is the data correct? Y/N");
char ny;
try {
ny = scan.findInLine(".").charAt(0);
if(ny == 'Y' || ny == 'y'){
System.out.print("Perfect, you just finished your inscription");
} if(ny != 'n' || ny != 'N'){
System.out.print("Sorry, start over again");
} if(ny != 'y' || ny != 'Y' || ny != 'N' || ny !='n'){
System.out.print("Please enter Y/N");
}
} catch(Exception e){
System.out.println(e.toString()รขโฌยฆ
System.exit(1);
}
} if(yn == 'n' || yn == 'N'){
System.out.print("You have chosen no");
} if(!(yn == 'y' || yn == 'Y' || yn == 'N' || yn == 'n')){
System.out.print("Please enter Y/N");
}
}
}
}
When i run the project I get the following error:
--------------------Configuration: test - JDK version 1.6.0_25 <Default> - <Default>--------------------
Enter your password: tito
Retype password: tito
Succesful input
Password characters are within margins, succesful output
Both password are correct, do you want to continue? Y/N y
You have choosen yes we are going to continue
Please enter your nickname: cyber
Please enter your email: [email protected]
Please enter city where you live: yes
Please enter your postal code: 4567
Please verify if your data is correct:
Password: tito
Nickname: cyber
City: yes
Postal code: 4567
Is the data correct? Y/N
java.lang.NullPointerException
Process completed.
How can i fix the NullPointerException??? any help??
I used the superclass exception but i wanted to see the error that why it appears the java.lang.null.pointer exception.
if I import: import static java.lang.System.out/in would it help??
Thanks!!
import java.util.Scanner;
class test {
public static void main(String args[]){
Scanner scan = new Scanner(System.in);
System.out.print("Enter your password: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String pass = null;
try {
pass = br.readLine();
} catch(IOException e) {
System.out.print("Error");
System.exit(1);
}
System.out.print("Retype password: ");
BufferedReader bro = new BufferedReader(new InputStreamReader(System.in));
String retype = null;
try {
retype = bro.readLine();
} catch(IOException e) {
System.out.print("Error");
System.exit(1);
} if(pass.equals(retype)) System.out.println("Succesful input"); else System.out.println("input incorrect");
int lenght = pass.length();
if(lenght > 10) System.out.println("Password too long");
if(lenght < 4) System.out.println("Password too short");
if(lenght <= 10 && lenght >= 4 && pass.equals(retype)) System.out.println("Password characters are within margins, succesful output");
if(lenght > 10 || lenght < 4 || (!(pass.equals(retype))))System.out.prinรขโฌยฆ or more errors have been spotted with your password, please be sure they are the same and are within margins");
if(pass.equals(retype) && lenght <= 10 && lenght >= 4){
System.out.print("Both password are correct, do you want to continue? Y/N ");
char yn;
yn = scan.findInLine(".").charAt(0);
if(yn == 'Y' || yn == 'y'){
System.out.println("You have choosen yes we are going to continue");
System.out.print("Please enter your nickname: ");
BufferedReader user = new BufferedReader(new InputStreamReader(System.in));
String nick = null;
try {
nick = user.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.print("Please enter your email: ");
BufferedReader mail = new BufferedReader(new InputStreamReader(System.in));
String email = null;
try {
email = mail.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.print("Please enter city where you live: ");
BufferedReader cit = new BufferedReader(new InputStreamReader(System.in));
String city = null;
try {
city = cit.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.print("Please enter your postal code: ");
String postal = null;
try {
postal = cit.readLine();
} catch(IOException e){
System.out.print("FATAL ERROR JUST OCURRED");
System.exit(1);
}
System.out.println("Please verify if your data is correct:");
System.out.println("Password: " + pass);
System.out.println("Nickname: " + nick);
System.out.println("City: " + city);
System.out.println("Postal code: " + postal);
System.out.println("Is the data correct? Y/N");
char ny;
try {
ny = scan.findInLine(".").charAt(0);
if(ny == 'Y' || ny == 'y'){
System.out.print("Perfect, you just finished your inscription");
} if(ny != 'n' || ny != 'N'){
System.out.print("Sorry, start over again");
} if(ny != 'y' || ny != 'Y' || ny != 'N' || ny !='n'){
System.out.print("Please enter Y/N");
}
} catch(Exception e){
System.out.println(e.toString()รขโฌยฆ
System.exit(1);
}
} if(yn == 'n' || yn == 'N'){
System.out.print("You have chosen no");
} if(!(yn == 'y' || yn == 'Y' || yn == 'N' || yn == 'n')){
System.out.print("Please enter Y/N");
}
}
}
}
When i run the project I get the following error:
--------------------Configuration: test - JDK version 1.6.0_25 <Default> - <Default>--------------------
Enter your password: tito
Retype password: tito
Succesful input
Password characters are within margins, succesful output
Both password are correct, do you want to continue? Y/N y
You have choosen yes we are going to continue
Please enter your nickname: cyber
Please enter your email: [email protected]
Please enter city where you live: yes
Please enter your postal code: 4567
Please verify if your data is correct:
Password: tito
Nickname: cyber
City: yes
Postal code: 4567
Is the data correct? Y/N
java.lang.NullPointerException
Process completed.
How can i fix the NullPointerException??? any help??
I used the superclass exception but i wanted to see the error that why it appears the java.lang.null.pointer exception.
if I import: import static java.lang.System.out/in would it help??
Thanks!!