jQuery in Action, 3rd edition
The moose likes Java in General and the fly likes please help me with my coding errors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "please help me with my coding errors " Watch "please help me with my coding errors " New topic

please help me with my coding errors

Andries Letsela

Joined: Oct 06, 2003
Posts: 3
public class Bursary
public Bursary(String aStudentNumber, String aBirthdate)
StudentNumber = aStudentNumber;
Birthdate = aBirthdate;
String message;
public int calcAge()
String sub = Birthdate.substring(0,4);
int Birthdate = Integer.parseInt(sub);
age = 2003 - Birthdate;
return age;
public int calcYear()
String sub = StudentNumber.substring(4,8);
int StudentNumber = Integer.parseInt(sub);
year = 2003 - StudentNumber;
return year;
public String determineBursary()
if(age >= 18 && age <= 25 && year <= 5)
message = "Accepted";
message = "Not accepted";
return message;
private String StudentNumber;
private String message;
private String Birthdate;
private int year;
private int age;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class BursaryTest
public static void main(String[] args) throws Exception
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
String studentNumber = console.readLine();

String birthdate = console.readLine();

Bursary myBursary = new Bursary(studentNumber, birthdate);

System.out.println("Number of yearsEnrolled : " + myBursary.calcYear());
System.out.println("Your age is : " + myBursary.calcAge());
System.out.println("Bursary : " + myBursary.determineBursary());

System.out.println("Do you want to continue: Yes/No");
String ans = console.readLine();

R Letsela.<br /> A
Herb Schildt
Ranch Hand

Joined: Oct 01, 2003
Posts: 253
I assume that BursaryTest and Bursary are in two separate files. Right?
In BursaryTest, input, which is used in this line
is not declared anywhere. Remember, in Java, variables must be declared before they are used.

For my latest books on Java, including Introducing JavaFX 8 Programming, see HerbSchildt.com
Andries Letsela

Joined: Oct 06, 2003
Posts: 3
Thanx i'll try t remember to declare all variables.
thanx millions times.
I agree. Here's the link: http://aspose.com/file-tools
subject: please help me with my coding errors
It's not a secret anymore!