There are 3 java classes in separate files and when I compile them...ERRORS!

If anyone could run those 2 classes separately and tell me the peoblems I will be really grateful coz I've used up my minds!

import java.util.*;


public class PageOne
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
private int option = 0;
RegisterTest entry = new RegisterTest();


System.out.println("--Welcome To The Owned Application--");
System.out.println("1. Login");
System.out.println("2. Register");


System.out.println("");
System.out.print("Enter Your Choice : ");


option = sc.nextInt();


switch(option)
{
case 1:


case 2: entry.Test2();
break;


default: System.out.println("Invalid Option...Enter Again");
System.out.println("");
System.out.print("Enter Your Choice : ");
option = sc.nextInt();
break;
}
}
}


import java.util.*;
import java.io.*;


public class Register
{
private String userEmail;
private String name;
private String password;
private int option;
private String inviterEmail;
private int dollars;


public Register()
{
userEmail = "";
name = "";
password = "";
option = 0;
inviterEmail = "";
dollars = 200;
}


public void setUserEmail(String newUserEmail)
{
userEmail = newUserEmail;
}


public void setName(String newName)
{
name = newName;
}


public void setPassword(String newPassword)
{
password = newPassword;
}


public void setOption(int newOption)
{
option = newOption;
}


public void setInviterEmail(String newInviterEmail)
{
inviterEmail = newInviterEmail;
}


public void Test1()
{
try {
FileOutputStream fOutputStream = new FileOutputStream("C:\\Documents and Settings\\mayank.a.2007\\Desktop\\SMU - 2nd Semester\\Object Oriented Application Development\\Project Facelift\\Code\\Database.txt");
Scanner sc = new Scanner(System.in);


fOutputStream.write(userEmail);
fOutputStream.write(name);
fOutputStream.write(password);
fOutputStream.write(option);
fOutputStream.write(inviterEmail);
fOutputStream.write("");


fOutputStream.close();
}
catch(FileNotFoundException e) {
System.out.println("Error Opening The Input File!" + e.getMessage());
System.exit(0);
}
catch (IOException e) {
System.out.println("IO Error!" + e.getMessage());
e.printStackTrace();
System.exit(0);
}
}
}


import java.util.*;


public class RegisterTest
{
public void Test2()
{
Register user = new Register();
Scanner sc = new Scanner(System.in);


private String userEmail;
private String name;
private String password;
private int option;
private String inviterEmail;


System.out.print("Enter Your Email : ");
userEmail = sc.nextLine();


System.out.print("Enter Your Name : ");
name = sc.nextLine();


System.out.print("Enter Your Password : ");
password = sc.nextLine();


System.out.print("Looking For ");
System.out.print("1 - Friendship");
System.out.print("2 - Dating");
System.out.print("3 - Relationship");
System.out.print("4 - Networking");
System.out.print("Enter Your Option : ");
option = sc.nextInt();


System.out.print("Enter Inviter's Email : ");
inviterEmail = sc.nextLine();


user.setUserEmail(userEmail);
user.setName(name);
user.setPassword(password);
user.setOption(option);
user.setInviterEmail(inviterEmail);
user.Test1();
}
}

WAITING.......................:)

Don't wait too much, you will be disappointed. Meaning that you should post the compile errors you get for each class and then we will try to help you. Because you are not using code tags and it is hard to read your code

There are 3 java classes in separate files and when I compile them...ERRORS!

If anyone could run those 2 classes separately and tell me the peoblems I will be really grateful coz I've used up my minds!

import java.util.*;


public class PageOne
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
private int option = 0;      //Illegal Start Of Expression
RegisterTest entry = new RegisterTest();


System.out.println("--Welcome To The Owned Application--");  //<identifier> expected and illegal start off type
System.out.println("1. Login"); //<identifier> expected and illegal start off type
System.out.println("2. Register"); //<identifier> expected and illegal start off type


System.out.println(""); //<identifier> expected and illegal start off type
System.out.print("Enter Your Choice : "); //<identifier> expected and illegal start off type


option = sc.nextInt(); //<identifier> expected


switch(option)
{
case 1:             // orphaned case


case 2: entry.Test2();
break;


default: System.out.println("Invalid Option...Enter Again");
System.out.println("");
System.out.print("Enter Your Choice : ");
option = sc.nextInt();
break;
}
}
}                      // class, enum or interface expected

I will post rest of the class with errors after seeing the errors in this one. Thanks.

Remove the "private" from "private int option ...".

Access modifiers only apply to class/instance variables, not local variables.

Add something to case 1 (or don't if you wish, as I believe that "error" is only a warning).

And, if that is really your complete code, most of the other errors may simply be a result of the first, so change that one and compile again.

and learn how to use codetags.

[code=language] [/code] Those are code tags and when you put them around your code it looks like this.

import java.util.*;

public class PageOne
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
private int option = 0;
RegisterTest entry = new RegisterTest();

System.out.println("--Welcome To The Owned Application--");
System.out.println("1. Login");
System.out.println("2. Register");

System.out.println("");
System.out.print("Enter Your Choice : ");

option = sc.nextInt();

switch(option)
{
case 1:

case 2: entry.Test2();
break;

default: System.out.println("Invalid Option...Enter Again");
System.out.println("");
System.out.print("Enter Your Choice : ");
option = sc.nextInt();
break;
}
}
}



import java.util.*;
import java.io.*;

public class Register
{
private String userEmail;
private String name;
private String password;
private int option;
private String inviterEmail;
private int dollars;

public Register()
{
userEmail = "";
name = "";
password = "";
option = 0;
inviterEmail = "";
dollars = 200;
}

public void setUserEmail(String newUserEmail)
{
userEmail = newUserEmail;
}

public void setName(String newName)
{
name = newName;
}

public void setPassword(String newPassword)
{
password = newPassword;
}

public void setOption(int newOption)
{
option = newOption;
}

public void setInviterEmail(String newInviterEmail)
{
inviterEmail = newInviterEmail;
}

public void Test1()
{
try {
FileOutputStream fOutputStream = new FileOutputStream("C:\\Documents and Settings\\mayank.a.2007\\Desktop\\SMU - 2nd Semester\\Object Oriented Application Development\\Project Facelift\\Code\\Database.txt");
Scanner sc = new Scanner(System.in);

fOutputStream.write(userEmail);
fOutputStream.write(name);
fOutputStream.write(password);
fOutputStream.write(option);
fOutputStream.write(inviterEmail);
fOutputStream.write("");

fOutputStream.close();
}
catch(FileNotFoundException e) {
System.out.println("Error Opening The Input File!" + e.getMessage());
System.exit(0);
}
catch (IOException e) {
System.out.println("IO Error!" + e.getMessage());
e.printStackTrace();
System.exit(0);
}
}
}



import java.util.*;

public class RegisterTest
{
public void Test2()
{
Register user = new Register();
Scanner sc = new Scanner(System.in);

private String userEmail;
private String name;
private String password;
private int option;
private String inviterEmail;

System.out.print("Enter Your Email : ");
userEmail = sc.nextLine();

System.out.print("Enter Your Name : ");
name = sc.nextLine();

System.out.print("Enter Your Password : ");
password = sc.nextLine();

System.out.print("Looking For ");
System.out.print("1 - Friendship");
System.out.print("2 - Dating");
System.out.print("3 - Relationship");
System.out.print("4 - Networking");
System.out.print("Enter Your Option : ");
option = sc.nextInt();

System.out.print("Enter Inviter's Email : ");
inviterEmail = sc.nextLine();

user.setUserEmail(userEmail);
user.setName(name);
user.setPassword(password);
user.setOption(option);
user.setInviterEmail(inviterEmail);
user.Test1();
}
}

Hey all u guys,

thnx a lottt it helped......:).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.