you must implement public class Student by following the instructions as follows exactly. You may reference Chapter 7 for the similar examples to get the ideas and concepts.
Each student must have the following 5 attributes (i.e., instance variables):
You must declare the following 3 static variables with proper initial values:
private static int countStudents = 0 ; // count the total number of students being constructed
private static double totalGpa = 0.0 ; // total GPA sum of all students // don’t use float
private static double averageGpa = 0.0 ; // average GPA of all students // don’t use float
You must create one constructor, 5 accessors (getters), and 5 mutators (setters) for this Student class.
The constructor method Student must do all the following completely and properly:
totalGpa += gpa ; // add this student’s gpa to totalGpa
averageGpa = totalGpa / countStudents ; // computer current averageGpa
You must also create the following 2 static methods:
(a) toString – to form a student record properly as a string for printing;
(b) printStudentRecord – to print the student record in a nice format using toString method.
Therefore, at least 13 methods are to be created by you.
You must write a while loop asking the user to enter student id, last name, first name, GPA, and phone number. Then, you print the student record nicely, and show the current student count, total GPA, and average GPA. Then, continue asking the user to enter next student’s data. If the student id is 0 (i.e., zero), thank the user and stop your program nicely.
You must test your program (as follows) in your static void main method. Another optional way (if you know how) is to write a client class to test your program accordingly.
========================================================================.
Your complete testing input and output for this lab assignment must be as follows:
>> Please enter student id, last name, first name, GPA, and phone number>
1 Doe John 3.0 626-111-5428
Student id: 1, Last Name: Doe, First Name: John, GPA: 3.00, Phone Number: 626-111-5428
Current Student Count: 1, Total GPA: 3.00, Average GPA: 3.00
>> Please enter student id, last name, first name, GPA, and phone number>
2 Smith Mary 4.0 626-222-5555
Student id: 2, Last Name: Smith, First Name: Mary, GPA: 4.00, Phone Number: 626-222-5555
Current Student Count: 2, Total GPA: 7.00, Average GPA: 3.50
>> Please enter student id, last name, first name, GPA, and phone number>
3 Stone Joe 2.0 626-333-5555
Student id: 3, Last Name: Stone, First Name: Joe, GPA: 2.00, Phone Number: 626-333-5555
Current Student Count: 3, Total GPA: 9.00, Average GPA: 3.00
>> Please enter student id, last name, first name, GPA, and phone number>
4 Lin Steve 1.0 626-444-4444
Student id: 4, Last Name: Lin, First Name: Steve, GPA: 1.00, Phone Number: 626-444-4444
Current Student Count: 4, Total GPA: 10.00, Average GPA: 2.50
>> Please enter student id, last name, first name, GPA, and phone number>
5 Li Pete 3.0 626-555-6666
Student id: 5, Last Name: Li, First Name: Pete, GPA: 3.00, Phone Number: 626-555-6666
Current Student Count: 5, Total GPA: 13.00, Average GPA: 2.60
>> Please enter student id, last name, first name, GPA, and phone number>
6 Bee Scott 4.0 626-666-6666
Student id: 6, Last Name: Bee, First Name: Scott, GPA: 4.00, Phone Number: 626-666-6666
Current Student Count: 6, Total GPA: 17.00, Average GPA: 2.8333333
>> Please enter student id, last name, first name, GPA, and phone number>
7 Codd April 3.80 626-777-7777
Student id: 7, Last Name: Cod, First Name: April, GPA: 3.80, Phone Number: 626-777-7777
Current Student Count: 7, Total GPA: 20.80, Average GPA: 2.9714
>> Please enter student id, last name, first name, GPA, and phone number>
0 no 0.00 no
>> Thank you for using our Student program! See you later!
Thanks for posting the question, here is the complete class and output screenshot
thank you and do give a thumbs up !!
--------------------------------------------------------------------------------------------------------------------------------------------
import java.util.Scanner; public class Student { private String studentID; private String lastName; private String firstName; private double gpa; private String phoneNumber; private static int countStudents = 0; private static double totalGpa = 0.0; private static double averageGpa = 0.0; public Student(String studentID, String lastName, String firstName, double gpa, String phoneNumber) { this.studentID = studentID; this.lastName = lastName; this.firstName = firstName; this.gpa = gpa; this.phoneNumber = phoneNumber; countStudents++; totalGpa += gpa; averageGpa = totalGpa / countStudents; } public String getStudentID() { return studentID; } public void setStudentID(String studentID) { this.studentID = studentID; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public double getGpa() { return gpa; } public void setGpa(double gpa) { this.gpa = gpa; } public String getPhoneNumber() { return phoneNumber; } public void setPhoneNumber(String phoneNumber) { this.phoneNumber = phoneNumber; } @Override public String toString() { return "Student id: " + getStudentID() + ", Last Name: " + getLastName() + ", First Name: " + getFirstName() + ", GPA: " + getGpa() + ", Phone Number: " + getPhoneNumber(); }
public void printStudentRecord() { System.out.println(this); System.out.println("Current Student Count: " + countStudents + ", Total GPA: " + String.format("%.2f",totalGpa) + ", Average GPA: " + String.format("%.2f",averageGpa) ); }
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); for (int i = 1; i <= 7; i++) { System.out.println("Please enter student id, last name, first name, GPA, and phone number>"); String[] data = scanner.nextLine().split("\\s+"); Student aStudent = new Student(data[0], data[1], data[2], Double.parseDouble(data[3]), data[4]); aStudent.printStudentRecord(); } System.out.println("Thank you for using our Student program! See you later!"); } }
--------------------------------------------------------------------
thanks !
you must implement public class Student by following the instructions as follows exactly. You may reference...
import java.util.Scanner; public class StudentClient { public static void main(String[] args) { Student s1 = new Student(); Student s2 = new Student("Smith", "123-45-6789", 3.2); Student s3 = new Student("Jones", "987-65-4321", 3.7); System.out.println("The name of student #1 is "); System.out.println("The social security number of student #1 is " + s1.toString()); System.out.println("Student #2 is " + s2); System.out.println("the name of student #3 is " + s3.getName()); System.out.println("The social security number...
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)...
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...
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...
You will create a class to keep student's information: name, student ID, and grade. The program will have the following functionality: - The record is persistent, that is, the whole registry should be saved on file upon exiting the program, and after any major change. - The program should provide the option to create a new entry with a student's name, ID, and grade. - There should be an option to lookup a student from his student ID (this will...
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...
Given a class called Student and a class called Course that contains an ArrayList of Student. Write a method called getDeansList() as described below. Refer to Student.java below to learn what methods are available. I will paste both of the simple .JAVA codes below COURSE.JAVA import java.util.*; import java.io.*; /****************************************************** * A list of students in a course *****************************************************/ public class Course{ /** collection of Students */ private ArrayList<Student> roster; /***************************************************** Constructor for objects of class Course *****************************************************/...
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)...
Create an application that allows you to enter student data that consists of an ID number, first name, last name, and grade point average. Depending on whether the student’s grade point average is at least 2.0, output each record either to a file of students in good standing (located at StudentsGoodStanding.txt) or those on academic probation (located at StudentsAcademicProbation.txt).
Create an application that allows you to enter student data that consists of an ID number, first name, last name, and grade point average. Depending on whether the student’s grade point average is at least 2.0, output each record either to a file of students in good standing (located at StudentsGoodStanding.txt) or those on academic probation (located at StudentsAcademicProbation.txt). Enter ZZZ to Quit. This is in Java