Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  StudentTest.java
Language: JAVA
Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication3;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class StudentTest {


    public static void main(String[] args) throws IOException
    {

    System.out.println("Students " + "Personal Details");


    String name;
    String course;
    int year=0;
    String studentNum;

    List<Student> studentsList = new ArrayList<Student>();


    for (int a = 0; a < 1; a++)
    {

    int studentNumber = (a + 1);
    System.out.println("");
    System.out.println("Please enter " + "data for student " + studentNumber);

    InputStreamReader converter = new InputStreamReader(System.in);
    BufferedReader in = new BufferedReader(converter);

    System.out.println("Enter Student "+ studentNumber + " Name:");
    name = in.readLine();

      System.out.println("Enter Student "+ studentNumber + " Course:");
    course = in.readLine();

    System.out.println("Enter Student " + studentNumber + " Year (Integer):");
    year = Integer.valueOf(in.readLine());

    System.out.println("Enter Student " + studentNumber + " Student Number:");
    studentNum = in.readLine();

    Student student = new Student(name, course, year, studentNum);

    studentsList.add(student); // add student
    }

  
  
    for (int b = 0; b < studentsList.size(); b++)
    {

        Student st = studentsList.get(b);
          int constantYear = 2014;
        String pending="PENDING";
           String neww="NEW";
       
              String enrolled="ENROLLED";
      String outYear = null;
        if(year < constantYear){
            outYear = enrolled;
        }
             else if(year == constantYear){
            outYear = neww;
        }
                else    if(year > constantYear){
            outYear = pending;
        }
          System.out.println(" ");
           System.out.println(" ");  
            System.out.println(" ");  
        System.out.println("Student Information : " + (b + 1));
       
        System.out.println("-Student Number: "+ st.getstudentNum());
        System.out.println("-Name: " + st.getName());
        System.out.println("-Course: " + st.getCourse());
         System.out.println("-Year of entry: " + st.getYear());
        System.out.println("-Enrollment status: " + outYear);


    }

    }

    private static class Student {

    private String course;
    private String name;

    private int year;

    private String studentNum;


    public Student(String course,String name, int year, String studentNum)
    {
          this.name = name;
 
        this.course = course;
        this.year = year;
        this.studentNum = studentNum;
    }

    public String getName() 
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }
    public String getCourse()
    {
        return course;
    }

    public void setCourse(String course)
    {
        this.course = course;
    }


    public int getYear() // year
    {
        return year;
    }

    public void setYear(int year)
    {
        this.year = year;
    }


  

    public String getstudentNum() // studentNum
    {
    return studentNum;
    }

    public void setstudentNum(String studentNum)
    {
        this.studentNum = studentNum;
        }
    
    }

}


          
Comments: