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.
Please use the diagram above to help answer the Question:
Create a project that:
code
solution
//output
//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;
}
}
Key Takeaways -To create 2 groups of 4 students (8 students in total) -NEEDS random GPAs for each student -No arrays ---...
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 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 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 { 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 • 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 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 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: • 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: 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, 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...