wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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
Author

please help me with my coding errors

Andries Letsela
Greenhorn

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";
else
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
{
do
{
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
System.out.println("studentNumber");
String studentNumber = console.readLine();

System.out.println("birthdate");
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();
}
while(input.equalsIgnoreCase("Yes"));
System.exit(0);
}
}


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

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


For my latest books on Java, including my Java Programming Cookbook, see HerbSchildt.com
Andries Letsela
Greenhorn

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
 
Similar Threads
Complete novice question
urgent help needed for assignment
reading a file, then replacing a string...
Troubles with output
why is my calstandardDev() returning 0?