Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Problem StudentDemo.java

$
0
0
I'm having trouble figuring out the second part of this problem. I've attached the student.java code for the first part, but I get stuck reading the .dat file into the StudentDemo and outputting that information. Any help would be appreciated. I'm not sure where to go from the student.java.

Assignment:
First you will create an Object class ‘Student’, with the attributes as indicated.

student name
major
credits

You will need to create a ‘testStudent’ class to instantiate student objects and print the report as specified under the ‘output’ heading. The ‘testStudent’ class will need to read from a text file (that you will create) named studentdata.dat. Each line of text will contain: student name, major, class name, class id, grade and credits for the class.

The output for you program will consist of:

Appropriate headings for each column of the report.

A line of output for each record read in from the studentdata.dat file. These lines of output (called detail lines) will include student name, major, class name, class id, grade, credits for the class and maybe a comment. The comments section of the detail line should display the String "Great Job!" if the student gets an 'A' grade.



Example:



Name Major Class Class ID Grade Comment

------- ---------------------------- ----------- ---------- ------- -------------

John Doe Computer Programming CSCI 160 123444 A Great Job!

Jane Doe Computer Programming CSCI 160 123444 B

public class Student
{
	private String firstName;	//Student first name.
	private String lastName;	//Student last name.
	private String major;		//Student major.
	private int credits;		//Number of credits.


	/**
	*The constructor accepts arguments for each field.
	*/

	public Student(String studentFirstName, String studentLastName, String studentMajor, int studentCredits)
	{
		firstName = studentFirstName;
		lastName = studentLastName;
		major = studentMajor;
		credits = studentCredits;
	}

	/**
	* The setfirstName method sets the student's first name.
	*/

	public void setfirstName(String studentFirstName)
	{
		firstName = studentFirstName;
	}
	/**
	* The setlastName method sets the student's last name.
	*/

	public void setlastName(String studentLastName)
	{
		lastName = studentLastName;
	}

	/**
	* The setMajor method sets the student's major.
	*/

	public void setMajor(String studentMajor)
	{
		major = studentMajor;
	}

	/**
	* The setCredits method sets the student's credits.
	*/

	public void setCredits(int studentCredits)
	{
		credits = studentCredits;
	}



	/**
	* The getfirstName returns student's first name.
	*/

	public String getfirstName()
	{
		return firstName;
	}

	/**
	*  The getlastName returns student's last name.
	*/

	public String getlastName()
	{
		return lastName;
	}

	/**
	* the getMajor method returns student's major.
	*/

	public String getMajor()
	{
		return major;
	}

	/**
	* the getMajor method returns student's major.
	*/

	public int getCredits()
	{
		return credits;
	}
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>