Question

Key Takeaways

-To create 2 groups of 4 students (8 students in total)

-NEEDS random GPAs for each student

-No arrays

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

app.java, student.java, and group.java as requested below.

app student group 1- creates 4 student objects First name 2- create a group object g1 using these 4 students name member 1 La

Please use the diagram above to help answer the Question:

Create a project that:

  • Has a student class
    • Instance variables for Firstname, last name , and age
    • random generated GPA
    • methods to return getinfo and semesterGPA
      • Build upon the solutions of the previous labs (e.g., using app.java and student.java)
      • You will need a version of student.java that has a working semesterGPA( ) method as specified in the last assignment
        • Very important:
          • For this lab it is important that you run semesterGPA() just once.
          • When semesterGPA() is executed, it should update the GPA attribute
          • Again, for this lab it is necessary that the student GPA is calculated just once. Otherwise, the group average GPA will never match with the displayed values because of the randomness in semesterGPA
          • When should you run semesterGPA then?
            • Running it in the constructor seems a good choice
  • Has a group class
    • group has a name
    • group has 4 students
    • group has at least 2 methods
      • A method that displays the group name and the name of each student in the group
      • A method that calculates and displays the average GPA of a group. Group average GPA is the average of all the group members' (students') GPA.
        • group GPA starts in student using the student GPA attribute.
        • For instance, we may have:
          • student #1, John, with a semesterGPA of 3.2;
          • student #2, Mary, with a semesterGPA of 3.5;
          • student #3, Emily, with a semesterGPA of 3.0, and
          • student #4, Peter, with a semesterGPA of 2.5,
          • which will give a group average GPA of (3.2 + 3.5 + 3.0 + 2.5)/4 = 3.05.
  • in app.java (the class with the main method)
    • Create 4 student objects
    • Create a group object g1 using the 4 student objects above
    • Using the group object (instance, variable) in app.java:
      • Display the group name, and information about each student in the group
      • Display the group average GPA
      • Display the semesterGPA of the third student in the group (retrieving information from the student class variables in the group, not from student variables in the app).
      • Pay attention, you have to use the group object (instance, variable) in app.java
        • Something like System.out.println(g1.______________);
    • Repeat the same process for another group object g2.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

code

solution

// Group.java public class Group String name; Student numberl; Student number2; Student number3; Student number4; public Groupublic double average_GPAO double (number1 .зете 3ter-GPA ( ) number3.semester GPA () + average- number2.semester GPA) numberStudent stobji new Student (Johny, Bravo, 21, 3.2); Student stobj2 new Student (Snoggle, Joy, 17, 3.5) Student stobj3// Create g2 Group gr2 ne Group (g2, stobj5, stobj6, stobj7, stobj8); // Display System.out.println(\n\n\nGroup Informatiopublic String get_Info) f return fname ++ lname of age+age+scored GPA GPA; public double semester_GPA) return GPA; publ

//output

E:javac Group.java E:\>javac Student-Java E:\>javac App-Java E:\〉java App Group Information Name of Group gr1 Name of Student

//copyable code

// Group.java

public class Group {

   

    String name;

    Student number1;

    Student number2;

    Student number3;

    Student number4;

  

    public Group(String theName, Student thenumber1, Student thenumber2, Student thenumber3, Student thenumber4) {

        name = theName;

        number1 = thenumber1;

        number2 = thenumber2;

        number3 = thenumber3;

        number4 = thenumber4;

    }

  

    public String get_Info() {

       

        String groupInfo = "Name of Group " + name + "\n" + "Name of Students in the Group" + "\n" + number1.get_Info()

                + "\n" + number2.get_Info() + "\n" + number3.get_Info() + "\n" + number4.get_Info();

      

        return groupInfo;

    }

    public double average_GPA() {

      

        double average = (number1.semester_GPA() + number2.semester_GPA() + number3.semester_GPA() + number4.semester_GPA())

                / 4;

        return average;

    }

    public double spStudentGPA(String theName) {

        if (number1.get_Name().equals(theName))

            return number1.semester_GPA();

       else if (number2.get_Name().equals(theName))

            return number2.semester_GPA();

       else if (number3.get_Name().equals(theName))

            return number3.semester_GPA();

       else

            return number4.semester_GPA();

    }

}

//App.java

public class App {

   

    public static void main(String args[]) {

       

        Student stobj1 = new Student("Johny", "Bravo", 21, 3.2);

        Student stobj2 = new Student("Snoggle", "Joy", 17, 3.5);

        Student stobj3 = new Student("Dwayne", "Johnson", 21, 3.0);

        Student stobj4 = new Student("Sej", "Jai", 25, 2.5);

       // Create g1

        Group gr1 = new Group("gr1", stobj1, stobj2, stobj3, stobj4);

       // Display

        System.out.println("Group Information ");

        System.out.println(gr1.get_Info());

     

        System.out.println("\nGroup Average: " + gr1.average_GPA());

     

        System.out.println("\nSemester GPA " + stobj3.get_Name() + " is = "

                + gr1.spStudentGPA(stobj3.get_Name()));

       // Create 4 student

        Student stobj5 = new Student("John", "Boy", 21, 7.86);

        Student stobj6 = new Student("Mary", "Janani", 17, 8.97);

        Student stobj7 = new Student("Emily", "Sharmi", 28, 3.15);

        Student stobj8 = new Student("Peter", "John", 20, 3.42);

       // Create g2

        Group gr2 = new Group("g2", stobj5, stobj6, stobj7, stobj8);

       // Display

        System.out.println("\n\n\nGroup Information ");

        System.out.println(gr2.get_Info());

      

        System.out.println("\nGroup Average: " + gr2.average_GPA());

       // Display

        System.out.println("\nSemester GPA of student " + stobj7.get_Name() + " is = "

                + gr2.spStudentGPA(stobj7.get_Name()));

    }

}

// Student.java

public class Student {

   

    String fname;

    String lname;

    int age;

    double GPA;

    public Student(String fName, String lName, int the_age, double the_GPA) {

        fname = fName;

        lname = lName;

        age = the_age;

        GPA = the_GPA;

    }

    public String get_Info() {

        return fname + " " + lname + " of age " + age + " scored GPA " + GPA;

    }

    public double semester_GPA() {

        return GPA;

    }

    public String get_Name() {

        return fname + " " + lname;

    }

}

Add a comment
Know the answer?
Add Answer to:
Key Takeaways -To create 2 groups of 4 students (8 students in total) -NEEDS random GPAs for each student -No arrays ---...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to...

    In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...

  • In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list...

    In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...

  • 2. Write a program named lab3 2.app that contains a class named Student to store student...

    2. Write a program named lab3 2.app that contains a class named Student to store student information Information that will be relevant to store is first name, last name, id number, GPA, and major (1) Define a member function named set0, which allows you to set all member variables. This function has an empty parameter list, and its return type is void. So, within the function you'll prompt for information. Note: For entering major, if you need a space, use...

  • I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student...

    I need code in java The Student class: CODE IN JAVA: Student.java file: public class Student {    private String name;    private double gpa;    private int idNumber;    public Student() {        this.name = "";        this.gpa = 0;        this.idNumber = 0;    }    public Student(String name, double gpa, int idNumber) {        this.name = name;        this.gpa = gpa;        this.idNumber = idNumber;    }    public Student(Student s)...

  • How do I start this Java: Inheritance problem? • person.java • student.java • studentAthlete.java • app.java...

    How do I start this Java: Inheritance problem? • person.java • student.java • studentAthlete.java • app.java • Students should apply consistent indenting in all submissions. This can be done via the NetBeans Source menu. Contents person First name Last name app Creates 1 student-athlete object Hometown Retinfo) 1-Displays the complete information about the student-athlete object student New attributes Maior attributes getinfo) method from the superlas person Student-athlete student's rankine Overrides the method from the superclass student Video from Professor Fisher...

  • A class allows a group of one or more member objects to have a series of...

    A class allows a group of one or more member objects to have a series of common characteristics and functions. Create a class (student) that contains the member characteristics: Student ID (string) Student Last Name (string) Student First Name (string) GPA (float) Number of enrolled classes (integer) The class functions are: setID (string passed to function to set Student ID) setLastName (string passed to function to set Student Last Name) setFirstName (string passed to function to set Student First Name)...

  • Java Project In Brief... For this Java project, you will create a Java program for a...

    Java Project In Brief... For this Java project, you will create a Java program for a school. The purpose is to create a report containing one or more classrooms. For each classroom, the report will contain: I need a code that works, runs and the packages are working as well The room number of the classroom. The teacher and the subject assigned to the classroom. A list of students assigned to the classroom including their student id and final grade....

  • Part I (20%) [File: Student.java] Create a class called Student that has the following stored properties:...

    Part I (20%) [File: Student.java] Create a class called Student that has the following stored properties: • StudentID • First Name • Last Name Class Student should have read/write properties, constructor(s) and should implement the Academic interface. For academic methods, return zero for average, zero for credits and false for graduate. Also implement the toString() method that returns the above information as a String. Part II (5%) [File: Academic.java] Create an interface Academic that declares three methods: 1. average -...

  • Create a class hierarchy to be used in a university setting. The classes are as follows:...

    Create a class hierarchy to be used in a university setting. The classes are as follows: The base class is Person. The class should have 3 data members: personID (integer), firstName(string), and lastName(string). The class should also have a static data member called nextID which is used to assign an ID number to each object created (personID). All data members must be private. Create the following member functions: o Accessor functions to allow access to first name and last name...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT