Hey guys I’m Gessa
Hi I m new, and desperately need HELP
I recently started my graduate studies where I have to take at least programming two, the last programming class I took was in my associates degree and one in the beginning of my bachelor's degree. And need some real help with some code and how to solve some problems if any of you can find the time to help me it would deeply appreciate this. Feel free to e mail me in private concerning my problem I will at one of them to this topic so that if you can and want to assist me you can see what I am having trouble with.
Thank you for your help and attention
1* This is the driver for the Course object. We have used methods rather than the code given by Liang to illustrate
more examples of how class objects are passed into these methods and to show how references to objects are the
means for changing the referenced object's state. *1
import java.uti!. *;
public class TestCourse
{
private static final String TERMINAL_NAME = "Q";
private static Scanner keyboard = new Scanner(System.in);
public static void main(String( ] args)
{
II String value that terminates user input
Course course 1 = new Course("Data Structures");
Course course2 = new Course("Database Systems");
addStudents( course 1);
System.out.println( );
addStudents( course2);
System.out.println( );
showCourse( course 1);
System.out.println( );
showCourse( course2);
}
1* Adds students to a course from keyboard input until the user enters the value of TERMINAL_NAME, thus
indicating that no more students will be added to the course. *1
private static void addStudents(Course theCourse)
{
String name;
II user-entered name of student to be added to the course
System.out.println("Enter names of students to enroll in II + theCourse.getCourseName( »;
System.out.println("Terminate the input with the name II + TERMINAL_NAME);
while (!(name = getName( ».equals(TERMINAL_NAME»
theCourse.addStudent(name );
II Returns string value from user input; kind of a glitzy way to do it with the use of a local String, but it works.
private static String getName( )
{
System.out.print("Name? ");
return keyboard.nextLine( );
1* Displays all the information about the specified course. Note how we are using the offset semantics on
studentNumber *1
private static void showCourse(Course theCourse)
{
int enrollment = theCourse.getNumberOfStudents( );
String name = theCourse.getCourseName( );
System.out.println("Here are the II + enrollment + II students enrolled in II + name + ":");
for (int studentNumber = 0; studentNumber < enrollment;)
{
++studentNumber;
System.out.println(" Student #" + studentNumber + ": II + theCourse.getStudent(studentNumber»;
Now it is time for you to write the code for the application, which we will name
ProcessACourse. Here is the pseudocode description of the main method to this application that
that you must develop:
instantiate object theCourse from keyboard input
enroll students in theCourse from keyboard input
display complete information abou tall values contained in theCourse
use theCourse to find and dispIlf>I the average GP A 0/ the students enrolled
get a reference to worstStudent, the one in theCourse with the lowest GP A '
get a reference to bestStudent, the one in theCourse with the highest GP A
display all the information contained in bestStudent and in worstStudent
Refinement
theCourse = createCourse( )
enroUStudents( theCourse)
showCourse(theCourse)
classAverage = getAverageGPA(theCourse)
worstStudent = getWorstStudent(theClass)
bestStudent = getBestStudent(theClass)
showW orstAndBest(bestStudent, worstStudent)
The above description, that refines the initial description virtually spells out the methods you
must code to solve this problem. There is little more I need say other than "go write the code."
Hints
However, I will make a few more points, one of which is a mandatory requirement while the
others are strong suggestions:
. Even though the run of ProcessACourse (the application) suggests that you know the
number of students before you get values for the students, you are not to assign a value to
the instance variable numberOfStudents directly! Use a for loop in the enrollStudents
method that will exit when the total number of students that should be in the course have
been added. In other words, don't mess with the objects you have coded. Make the
strategy suit the object rather than making the object suit the strategy.
. The create Course method only gets values for the courseName and the
professorsName (that's all you need for the constructor, right?). The assignment of
students is carried out in the enrollStudents method.
. The enrollStudents methodalready has a lot to do besides instantiating all the students in
the theCourse. It displays some prompts, and it gets a value for the local variable that
will be the numberOfStudents in the course. A smart approach to keep the code short is
to write a sequence like
student = theCourse.getStudent(studentNo); II get a reference
student = createStudent(studentNo);
II assign object to the reference
. an initial description for the for loops you will need to implement a number of the
methods is as follows:
for (int studentNo = 0; studentNo < totalStudents; )
{
++StudentNo;
II additional code
}
The value of totalStudents will be the same in every method that uses the for loop
strategy, but the way to get this value may be different within some of the methods.
I believe I have given you quite a bit on which to think. I am not expecting any sort of
cookie-cutter code that is forced to resemble all the hints I have given. Just develop the methods
you need to, and see if their final implementation is supported by the hints given. And let that be
my final hint/suggestion!