Results 1 to 2 of 2

Thread: Need some help

  1. #1
    zulkey is offline Member
    Join Date
    Nov 2010
    Posts
    2
    Rep Power
    0

    Cool Need some help

    need some help...actuallythis is my assignment..i have done a little bit but the rest i no idea what to do... some one ploease guide me....i attach my assignment and my solution please comment and guide me...

    thank you


    Consider the following Student class specification:

    Java Code:
    public Student() //CONSTRUCTOR
       Initialized the attributes
    
    public String name ()
    This Student’s name
    
    public String address()
    This Student’s address
    
    public String matric ()
       This Student’s matric number
    
    public int  creditHours ()
       Number of credit hours this  Student enrolled in
    
    public int  fees ()
       This Student’s fees for the semester
    
    public int feesPaid ()
       Amount this Student has paid so far for this semester
    
    public void changeName(String newName)
           Change the name of this Student 
    
    public void changeAddress (String newAddress)
           Change the address of this Student
    
    public void changeMatric(String newMatric)
           Change the matric of this Student
    
    public void payFees(int amout)
           Pay specified amount of fees
    
    public void  registerCourses(Course course)
           Register course(s) for  this Student
    
    public void  displayCourses(Course course)
           Display courses registered by this Student





    The methods registerCourses and displayCourses in the class Student use another class - class Course. The specification for the class Course is given below:

    Java Code:
    public void registerCourses (String courses[], int numberOfCourses)
            Register the courses to this Student
    
    public void displayCourses()
           Display courses registered by this Student

    i. Write the complete program for the classes Student and Course above (Assume that the fees are $100 per credit hour, student can only register a maximum of 5 courses and minimum of 1 course per semester, all the attributes should be declared as private).

    ii. Test the above class program in a new class which has the main()method (your main() program should be interactive)



    This is what i can do....


    Java Code:
    public class student {
    	public String name;
    	public String adress;
    	public String matric;
    	public int creditHour;
    	public int fee;
    	public int feePaid;
    	
    	public student (String st_name, String st_adress, String st_matric) {
    		name = st_name;
    		adress = st_adress;
    		matric = st_matric;
    	}
    	
    	public String getName(){
    		return name;
    	}
    	public void setName(String name){
    		this.name = name;
    	}
    	public String getAdress(){
    		return adress;
    	}
    	public void setAdress(String adress){
    		this.adress = adress;
    	}
    	public String getMatric(){
    		return matric;
    	}
    	public void setMatric(String matric){
    		this.matric = matric;
    	}
    	public int getcreditHours()
    	{
    		return creditHour;
    	}
    	public void setcreditHours(int hours)
    	{
    		creditHour = hours;
    	}
    	public int getfee()
    	{
    		return fee;
    	}
    	public void setfee (int money)
    	{
    		fee = money;
    	}
    	public int getfeePaid()
    	{
    		return feePaid;
    	}
    	public void setfeePaid(int paid)
    	{
    		feePaid = paid;
    	}
    
    }
    thank you
    Moderator Edit: Code tags added
    Last edited by Fubarable; 11-28-2010 at 12:45 PM. Reason: Moderator Edit: Code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by zulkey View Post
    need some help...actuallythis is my assignment..i have done a little bit but the rest i no idea what to do... some one ploease guide me....i attach my assignment and my solution please comment and guide me...

    thank you


    Consider the following Student class specification:

    Java Code:
    public Student() //CONSTRUCTOR
       Initialized the attributes
    
    public String name ()
    This Student’s name
    
    public String address()
    This Student’s address
    
    public String matric ()
       This Student’s matric number
    
    public int  creditHours ()
       Number of credit hours this  Student enrolled in
    
    public int  fees ()
       This Student’s fees for the semester
    
    public int feesPaid ()
       Amount this Student has paid so far for this semester
    
    public void changeName(String newName)
           Change the name of this Student 
    
    public void changeAddress (String newAddress)
           Change the address of this Student
    
    public void changeMatric(String newMatric)
           Change the matric of this Student
    
    public void payFees(int amout)
           Pay specified amount of fees
    
    public void  registerCourses(Course course)
           Register course(s) for  this Student
    
    public void  displayCourses(Course course)
           Display courses registered by this Student





    The methods registerCourses and displayCourses in the class Student use another class - class Course. The specification for the class Course is given below:

    Java Code:
    public void registerCourses (String courses[], int numberOfCourses)
            Register the courses to this Student
    
    public void displayCourses()
           Display courses registered by this Student

    i. Write the complete program for the classes Student and Course above (Assume that the fees are $100 per credit hour, student can only register a maximum of 5 courses and minimum of 1 course per semester, all the attributes should be declared as private).

    ii. Test the above class program in a new class which has the main()method (your main() program should be interactive)



    This is what i can do....


    Java Code:
    public class student {
    	public String name;
    	public String adress;
    	public String matric;
    	public int creditHour;
    	public int fee;
    	public int feePaid;
    	
    	public student (String st_name, String st_adress, String st_matric) {
    		name = st_name;
    		adress = st_adress;
    		matric = st_matric;
    	}
    	
    	public String getName(){
    		return name;
    	}
    	public void setName(String name){
    		this.name = name;
    	}
    	public String getAdress(){
    		return adress;
    	}
    	public void setAdress(String adress){
    		this.adress = adress;
    	}
    	public String getMatric(){
    		return matric;
    	}
    	public void setMatric(String matric){
    		this.matric = matric;
    	}
    	public int getcreditHours()
    	{
    		return creditHour;
    	}
    	public void setcreditHours(int hours)
    	{
    		creditHour = hours;
    	}
    	public int getfee()
    	{
    		return fee;
    	}
    	public void setfee (int money)
    	{
    		fee = money;
    	}
    	public int getfeePaid()
    	{
    		return feePaid;
    	}
    	public void setfeePaid(int paid)
    	{
    		feePaid = paid;
    	}
    
    }


    Some things about your post are confusing to me:

    • It describes class fields/attributes as public: public String name, although states in the instructions that all attribuites should be private.
    • There's a parenthesis at the end of each field: public String name () -- but only methods and constructors use parenthesis in this manner.
    • What you state is the specification for the Course class, is nothing more than a slight alteration of the two Student methods that use Course.


    Can you link us to the actual web site that displays the assignment? Either that or post the actual assignment?

    Other issues: you state "this is what i can do...." and post some code, but you don't ask an actual question. What's confusing you? What problem can you not solve? The more specific your question, usually the more helpful our answers can be.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •