Am writing this program using two classes for my school project from last 4 days. I have completed this program I think but when am running this program, it shows no error also it doesn't show any logic or runtime error..just got blank screen after compiling. Am wondering that why its not printing anything..trying from last 8-9 hrs but no luck. I bet that I missed something silly and cant figure that out. So if any one can help me then I greatly appreciate. Thank You
public class Student
{
private String name; //Name of Student
private int matricNo; //Student Number
private int yearOfBirth; //Students DOB
private int age; //Students Age
private double fees; //Fees for the each course
private int numberOfCoursesRegistered; //number of courses that students wants to register
private String[ ] subjectName;
private boolean registered= false;
public Student(String NAME, int MATRIC, int B_YEAR)
{
name= NAME;
yearOfBirth=B_YEAR;
matricNo= MATRIC;
numberOfCoursesRegistered=0;
subjectName= new String[3];
calculateAge();
}
private void calculateAge()
{
int currentYear=2008;
age= currentYear-yearOfBirth;
}//calculateAge
public void calculateFee()
{
if (registered==true)
fees=numberOfCoursesRegistered*350;
}//calculateFee
public void registerSubject (String subject1)
{
if (registered==false)
{
subjectName[0]=subject1;
numberOfCoursesRegistered=1;
registered=true;
}
else
System.out.println("You already registered");
}// registerSubject
public void registerSubject (String subject1, String subject2)
{
if (registered==false)
{
subjectName[0]=subject1;
subjectName[1]=subject2;
numberOfCoursesRegistered=2;
registered=true;
}
else
System.out.println("You already registered");
}// registerSubject
public void registerSubject (String subject1, String subject2, String subject3)
{
if (registered==false)
{
subjectName[0]=subject1;
subjectName[1]=subject2;
subjectName[3]=subject3;
numberOfCoursesRegistered=3;
registered=true;
}
else
System.out.println("You already registered");
}
// registerSubject
public void displaylnfo ( )
{
if (registered==true)
{
System.out.println("Name: " + name);
System.out.println("Matric: " + matricNo);
System.out.println("Year of Birth: " + yearOfBirth);
System.out.println("age " +age);
System.out.println("Fees: " + fees);
System.out.println("No of courses registered:+numberOfCoursesRegistered");
System.out.println("Courses registered are:");
for (int count=0; count < numberOfCoursesRegistered; count++)
System.out.println(subjectName[count]);
} //if
else
System.out.println("Information cannot be displayed because you have not registered");
} //displayInfo
}//class
This is another class
public class FinalStudent
{
public static void main(String[]args){
Student John = new Student ("John Smith" , 2345 , 1969);
John.registerSubject("Java Programming");
John.calculateFee();
}
}