Results 1 to 5 of 5
  1. #1
    Shree is offline Member
    Join Date
    Jul 2014
    Posts
    3
    Rep Power
    0

    Default Need help with Java Project - Array

    I need help with Array in Java, new to Java and having a hard time.... Would really appreciate suggestions, explanation or else... Thank you very much in advance. Below is what it is asked:

    2. Modify the Student class as follows:
    a. Each Student object should also contain an array for a schedule (collection) of courses. The instance
    variable declaration will look something like this: private Course[] schedule;
    b. A Student can register for as many as 6 classes per semester and up to 3 semesters in advance
    c. Modify the constructors so that each Student has a schedule.
    e. Modify the toString method so the Student schedule is printed AFTER the studentís name and address. If you
    are reusing code from Project 5, comment out the code that prints test scores and average. Use a for-loop to
    print the studentís schedule.

    3. Create a class for a Course that contains the following instance variables (all can be Strings):
    a. Term (e.g., 20151 for Fall 2014, 20152 for Spring 2015, 20152 for Summer 2015)
    b. Course Number (e.g., 368010)
    c. Location - Building and Room Number (e.g., E207, M2102)
    d. Instructor (Lastname, Firstname as one String with a comma in the middle Ė ďRice, CondoleezzaĒ).
    e. Your Course needs a constructor that sets all instance values based on parameter values.
    f. Use a static variable like count to keep up with the number of courses you create (for all Students).
    g. Your Course class will need four methods to SET the instance variables.
    h. Your Course class will need four methods to GET the instance variables.
    i. Your Course class will need a toString method that prints the Course information in this format (use a tab
    ď\tĒ between each item):
    Term: 20131 Course Num: 368010 Location: M2102 Instructor: Rice, Condoleezza

    4. Modify the StudentBody main method :
    a. Use an array to hold all the Students entered in one session; you can hard code some examples to test your
    code before perfecting the while loops in the next step.
    b. Use nested while loops to 1) enter students into the studentBody array and 2) enter courses into the
    studentís schedule.
    c. Display prompts to the user for:
    1) entering a studentís name
    2) entering a studentís addresses (school and home)
    3) adding courses to the studentís schedule
    4) ending data entry for the student; if you are finished entering data for the student, print the student.
    5) ending data entry for all students; if you are finished entering students, print the number of students,
    print the number of courses for all students (the Course static variable), and the index and studentís name for all
    students (use a for-loop for the studentBody array).
    c. Output: after the user indicates the end of course entry for a student, print out the student
    d. Output: after the user indicates the end of student entry (no more students), use appropriate labels and:
    1) print the number of students
    2) print the number of courses for all students (the Course static variable)
    3) print the index and the studentís name for all students (use a for-loop for the studentBody array)

    Student Class:

    public class Student
    {
    private String firstName, lastName;
    private Address homeAddress, schoolAddress;
    private Integer test1, test2, test3;
    private Course[] schedule;

    // ---------------------------------------------------------------------------------------
    // Constructor: Sets up this student with the specified values.
    // ---------------------------------------------------------------------------------------

    public Student (String first, String last, Address home, Address school)
    {
    firstName = first;
    lastName = last;
    homeAddress = home;
    schoolAddress = school;
    test1 = 0;
    test2 = 0;
    test3 = 0;
    }

    public Student (String first, String last, Address home, Address school, int cTest1, int cTest2, int cTest3)
    {
    firstName = first;
    lastName = last;
    homeAddress = home;
    schoolAddress = school;
    test1 = cTest1;
    test2 = cTest2;
    test3 = cTest3;
    }

    // Constructor: Creates an initially empty collection

    public CourseSchedule ()
    {
    schedule = new Course[18];
    count = 0;
    }

    // Adds a Course to the Schedule

    public void addCourse (String first, String last, String course)
    {
    if (count == schedule.length)
    increaseSize();

    schedule[count]= new Course (String first, String last, String course);

    count++;
    }


    //To set individual test scores, you can use a switch statement or an if-else ladder.

    public void setTestScores(int testNum, int score)
    {
    if(testNum == 1)
    test1 = score;
    else if(testNum == 2)
    test2 = score;
    else if(testNum == 3)
    test3 = score;
    }

    public int getTestScores(int testNum)
    {
    if(testNum == 1)
    return test1;
    else if(testNum == 2)
    return test2;
    else
    return test3;
    }

    public double testAverage(int test1, int test2, int test3)
    {
    double avg = (double)(test1 + test2 + test3)/3;
    return avg;
    }

    // ---------------------------------------------------------------------------------------
    // Returns a string description of this Student object.
    // ---------------------------------------------------------------------------------------

    public String toString()
    {
    String result;

    result = firstName + " " + lastName + "\n";
    result += "Home Address:\n" + homeAddress + "\n";
    result += "School Address:\n" + schoolAddress + "\n";
    //result += "Test1: " + test1 + " ";
    //result += "Test2: " + test2 + " ";
    //result += "Test3: " + test3 + "\n";
    //result += "Average: " +(double)(test1 + test2 + test3)/3;
    result += "\n\nCourse List:\n\n";

    for (int course = 0; course < count; course++)
    report += schedule[course].toString() + "\n";


    return result;
    }
    }

  2. #2
    Shree is offline Member
    Join Date
    Jul 2014
    Posts
    3
    Rep Power
    0

    Default Re: Need help with Java Project - Array

    I am working on the first one, Student class.

  3. #3
    DayKema is offline Member
    Join Date
    Jul 2014
    Posts
    23
    Rep Power
    0

    Default Re: Need help with Java Project - Array

    Dont say you need help and not give a real question.

    You never asked a specific question we can help you with.

  4. #4
    Shree is offline Member
    Join Date
    Jul 2014
    Posts
    3
    Rep Power
    0

    Default Re: Need help with Java Project - Array

    I am working on the first part of the question.
    a. Each Student object should also contain an array for a schedule (collection) of courses. The instance
    variable declaration will look something like this: private Course[] schedule;
    b. A Student can register for as many as 6 classes per semester and up to 3 semesters in advance
    c. Modify the constructors so that each Student has a schedule.
    e. Modify the toString method so the Student schedule is printed AFTER the student’s name and address. If you
    are reusing code from Project 5, comment out the code that prints test scores and average. Use a for-loop to
    print the student’s schedule.
    I am confused on b and c which are as below:
    A Student can register for as many as 6 classes per semester and up to 3 semesters in advance
    c. Modify the constructors so that each Student has a schedule.

  5. #5
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    450
    Rep Power
    7

    Default Re: Need help with Java Project - Array

    @Shree

    Are you looking out freelancers to help out your project work? If yes, this is not right place for you.

    I would recommend you to kick off your coding and come up here if you struck. That makes sense and makes you feels a creative programmer.
    Mak
    (Living @ Virtual World)

Similar Threads

  1. Replies: 2
    Last Post: 06-26-2014, 08:43 PM
  2. Replies: 7
    Last Post: 11-27-2012, 11:16 AM
  3. Clueless on an Array project
    By progamer3054 in forum New To Java
    Replies: 1
    Last Post: 11-21-2012, 08:58 PM
  4. Need help with Java Project - Array -
    By Michelle66 in forum New To Java
    Replies: 4
    Last Post: 07-20-2012, 03:56 PM
  5. Array project for class
    By circuspeanuts in forum New To Java
    Replies: 7
    Last Post: 04-17-2009, 01:44 AM

Posting Permissions

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